home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc302emb.zip / MICROC.DOC < prev    next >
Text File  |  1994-03-18  |  190KB  |  4,962 lines

  1.           
  2.           
  3.           
  4.           
  5.           
  6.           
  7.           
  8.           
  9.           
  10.           ===========================================================
  11.                 DDDDD           DDDDD               SSSS
  12.                  D   Dunfield    D   D             S
  13.                  D   D           D   Development    SSSS 
  14.                  D   D           D   D                  Systems
  15.                 DDDDD           DDDDD               SSSS
  16.           ===========================================================
  17.           MM   MM  IIIIIII    CCCC   RRRRRR     OOO             CCCC
  18.           M M M M     I      C    C  R     R   O   O           C    C
  19.           M  M  M     I     C        R     R  O     O         C
  20.           M     M     I     C        RRRRRR   O     O  -----  C
  21.           M     M     I     C        R   R    O     O         C
  22.           M     M     I      C    C  R    R    O   O           C    C
  23.           M     M  IIIIIII    CCCC   R     R    OOO             CCCC
  24.           ===========================================================
  25.     
  26.     
  27.     
  28.     
  29.     
  30.                              A compact 'C' compiler
  31.                                       for
  32.                                C-FLEA processors.
  33.     
  34.     
  35.                                 Technical Manual
  36.     
  37.     
  38.     
  39.     
  40.     
  41.                                   Release 3.02
  42.     
  43.                                Revised 09-Feb-94
  44.     
  45.     
  46.     
  47.     
  48.     
  49.     
  50.     
  51.     
  52.     
  53.     
  54.     
  55.     
  56.                        Copyright 1988-1994 Dave Dunfield
  57.                               All rights reserved
  58.     MICRO-C C-FLEA Compiler                                          Page: 1
  59.  
  60.  
  61.     1. INTRODUCTION
  62.     
  63.           This C-FLEA developers kit includes pre-configured implementations
  64.        of  the  MICRO-C  compiler,  ASMCF  cross  assembler,   and   related
  65.        utilities. The  package  provides  everything  you  need  to  perform
  66.        software development in  either  'C'  or  assembler  for  the  C-FLEA
  67.        virtual processor.
  68.     
  69.        1.1 Memory configuration
  70.     
  71.              The code produced by this compiler runs on the  C-FLEA  virtual
  72.           processor,  which  can  be  emulated  by  several  different  host
  73.           microprocessors. The exact memory layout may vary depending on the
  74.           host. In the default system, the program is placed  in  memory  at
  75.           address $1000, and the stack grows down from $0FFF, while data  is
  76.           allocated beginning at $0000.
  77.     
  78.              You may run the code in other configurations, by re-configuring
  79.           the memory setup in the PREFIX.ASM and MIDDLE.ASM files located in
  80.           the LIBCF sub directory.
  81.     
  82.              Virtually any memory  configuration  within  the  limits  of  a
  83.           single 64K address space can be  handled  by  our  PC  based  EMCF
  84.           Virtual Machine Simulator.
  85.     
  86.        1.2 Code Portability
  87.     
  88.              With few exceptions, this compiler follows the  syntax  of  the
  89.           "standard" UNIX compiler (within  its  subset  of  the  language).
  90.           Programs written in MICRO-C should compile with few changes  under
  91.           other "standard" compilers.
  92.     
  93.           1.2.1 Unsupported Features:
  94.     
  95.                 MICRO-C does not currently support the following features of
  96.              standard 'C':
  97.     
  98.                     Long / Double / Float / Enumerated data types,
  99.                     Typedef and Bit fields.
  100.     
  101.           1.2.2 Additional Features
  102.     
  103.                 MICRO-C provides a few additional  features  which  are  not
  104.              always included in "standard" 'C' compilers:
  105.     
  106.                     Unsigned character variables, Nested comments, 16 bit
  107.                     character constants, Inline assembly code capability.
  108.     MICRO-C C-FLEA Compiler                                          Page: 2
  109.  
  110.  
  111.        1.3 The compiling process
  112.     
  113.              There are five  programs  which  work  together  to  completely
  114.           compile a MICRO-C program:
  115.     
  116.              The PREPROCESSOR (MCP) takes  the  original  'C'  source  file,
  117.           performs MACRO expansion and incorporates the contents of  INCLUDE
  118.           files  to  get  a  "pure"  'C'  output  file.  A   less   powerful
  119.           pre-processor is also contained inside the COMPILER, which  allows
  120.           this step to  be  skipped  for  programs  which  use  only  simple
  121.           pre-processor functions.
  122.     
  123.              The COMPILER (MCCCF) reads  a  file  containing  a  'C'  source
  124.           program, and translates it into an  equivalent  assembly  language
  125.           program.
  126.     
  127.              The OPTIMIZER (MCOCF) reads the assembly language  output  from
  128.           the compiler identifying and replacing "general" code produced  by
  129.           the compiler with  more  efficent  code  which  is  equivalent  in
  130.           specific cases. This step is  optional,  allowing  you  to  choose
  131.           between faster compile time and greater program efficency.
  132.     
  133.              The SOURCE LINKER (SLINK) combines the assembly language output
  134.           from the compiler with any  required  routines  from  the  runtime
  135.           library, to create an entire program file.
  136.     
  137.              The ASSEMBLER  (ASMCF)  assembles  this  program  file  into  a
  138.           downloadable binary image in either INTEL  or  MOTOROLA  hex  file
  139.           format.
  140.     MICRO-C C-FLEA Compiler                                          Page: 3
  141.  
  142.  
  143.     2. THE COMMAND CO-ORDINATOR
  144.     
  145.           'CC' is a utility which co-ordinates  the  execution  of  programs
  146.        required for each step of the compilation process to provide a simple
  147.        "one step" compilation  command.  This  MICRO-C  package  includes  a
  148.        version of  the  command  co-ordinator  which  handles  the  commands
  149.        necessary to compile for the C-FLEA  processor  (MCP,  MCCCF,  MCOCF,
  150.        SLINK, ASMCF).
  151.     
  152.        2.1 The CCF command
  153.     
  154.              The format of the 'CCF' command is:
  155.     
  156.                               CCF <name> [options]
  157.     
  158.           2.1.1 Command line options
  159.     
  160.                 -A      - produce ASSEMBLER (.ASM) output file
  161.                 -C      - Include 'C' source as comments in ASM files
  162.                 -F      - Fold identical string constants.
  163.                 -I      - Output INTEL hex file (default is MOTOROLA)
  164.                 -K      - KEEP all temporary files (do not delete)
  165.                 -L      - Generate assembly .LST file
  166.                 -M      - Invoke xasm MACRO processor (See XASM manual)
  167.                 -O      - OPTIMIZE the output code (using MCOCF)
  168.                 -P      - use the extended PRE-PROCESSOR (MCP)
  169.                 -Q      - QUIET mode (suppress informational messages)
  170.                 -X      - produce eXtended ASM file (includes libraries)
  171.                 H=mcdir - specify MICRO-C home directory
  172.                 T=mctmp - specify prefix for TEMPORARY files
  173.     
  174.                 name=xx - Predefine macro symbol (use with -P only)
  175.     
  176.                 When executing the sub-commands, CCF will search the MICRO-C
  177.              home directory, as well as any  directories  specified  in  the
  178.              'PATH' environment variable. Libraries are  accessed  from  the
  179.              MICRO-C home directory only.
  180.     
  181.                 The environment variable 'MCDIR' is  examined  to  determine
  182.              the path to  the  MICRO-C  home  directory.  If  MCDIR  is  not
  183.              defined, CCF will assume the string  '\MC'.  You  may  override
  184.              this directory by using the 'h=' option on the command line.
  185.     
  186.                 Intermediate  results  from  each  command  are  stored   in
  187.              "temporary" files, which are fed as input to the next  command.
  188.              Temporary files will be deleted once they are no longer needed,
  189.              except in the case where a command fails.  When  this  happens,
  190.              any temporary file which  was  being  used  as  input  to  that
  191.              command will not be deleted, allowing you to examine it for the
  192.              cause of the error.
  193.     MICRO-C C-FLEA Compiler                                          Page: 4
  194.  
  195.  
  196.                 The environment variable 'MCTMP' is examined to determine  a
  197.              prefix to prepend to temporary file  names.  If  MCTMP  is  not
  198.              defined, CCF  assumes  the  default  prefix  of  '$'.  You  may
  199.              override this prefix by using the 't=' option  on  the  command
  200.              line.
  201.     
  202.                 Here are example 'SET' commands suitable  for  inclusion  in
  203.              the AUTOEXEC.BAT file, of an IBM/PC based MICRO-C system  which
  204.              has the home directory in 'C:\MC', and a TEMP  directory  on  a
  205.              RAMDISK as drive 'D':
  206.     
  207.                     SET MCDIR=C:\MC
  208.                     SET MCTMP=D:\TEMP\      (Note trailing '\')
  209.     
  210.                 The '-A' option causes  CCF  to  bypass  the  assembler  and
  211.              linker, and produce an assembly source file (<name>.ASM) as the
  212.              output file. If the '-C' option is also used,  this  file  will
  213.              contain the 'C' source code in the form of comments. NOTE:  The
  214.              source code inserted by '-C' will  restrict  the  optimizer  to
  215.              operate only on sections of code produced by a single 'C' line.
  216.     
  217.                 The '-F' option causes the compiler to  "fold"  its  literal
  218.              pool (the area of memory where string  constants  are  stored).
  219.              This means that identical strings  not  contained  in  explicit
  220.              variables, will occur only once in memory. Since most  programs
  221.              never modify such strings, it is usually safe to do this.  Note
  222.              however that this is a violation of the 'C' standard ("The  'C'
  223.              Programming Language"  page  181  -  "All  strings,  even  when
  224.              written identically, are distinct"),  and  it  is  possible  to
  225.              write programs which will not work properly when this option is
  226.              used.
  227.     
  228.                 The '-X' option is similar to '-A', except that the  program
  229.              is passed through the source linker, resulting in a ".ASM" file
  230.              containing the complete program,  including  startup  code  and
  231.              library functions.
  232.     
  233.                 The  '-M'  option  causes  CCF  to  invoke  the  xasm  MACRO
  234.              processor, allowing macros to be used in your  inline  assembly
  235.              code (See XASM manual). For the sake of efficency, this is done
  236.              BEFORE the program is passed through the  source  linker.  This
  237.              means that macros  in  files  from  the  library  will  NOT  be
  238.              processed. If library files  contain  macros,  they  should  be
  239.              processed BEFORE they are placed in the library.
  240.     
  241.                 If any of the programs executed  by  CCF  fail  to  complete
  242.              properly, CCF will show the message "PGM  failed  (RC)",  where
  243.              PGM is the name of the offending program, and  RC  is  the  DOS
  244.              return code value. Common RC values under MSDOS are:
  245.     
  246.                 2   - Command not found (Check MCDIR and PATH setup)
  247.                 3   - Path not found    (Check MCDIR and PATH setup)
  248.                 254 - Program found errors during processing
  249.                 255 - Program was invoked with incorrect arguments
  250.     MICRO-C C-FLEA Compiler                                          Page: 5
  251.  
  252.  
  253.     3. THE MICRO-C PROGRAMMING LANGUAGE
  254.     
  255.           The following pages contain a brief summary of  the  features  and
  256.        constructs implemented in MICRO-C.
  257.     
  258.           This document does not  attempt  to  teach  'C'  programming,  and
  259.        assumes that the reader is familiar with the language.
  260.     
  261.        3.1 Constants
  262.     
  263.              The following forms of constants are supported by the compiler:
  264.     
  265.                 <num>       - Decimal number        (0 - 65535)
  266.                 0<num>      - Octal number          (0 - 0177777)
  267.                 0x<num>     - Hexidecimal number    (0x0 - 0xffff)
  268.                 '<char>'    - Character             (1 or 2 chars)
  269.                 "<string>"  - Address of literal string.
  270.     
  271.              The following "special" characters may be used within character
  272.           constants or strings:
  273.     
  274.                 \n          - Newline (line-feed)   (0x0a)
  275.                 \r          - Carriage Return       (0x0d)
  276.                 \t          - Tab                   (0x09)
  277.                 \f          - Formfeed              (0x0c)
  278.                 \b          - Backspace             (0x08)
  279.                 \<num>      - Octal value <num>     (Max. three digits)
  280.                 \x<num>     - Hex value <num>       (Max. two digits)
  281.                 \<char>     - Protect character <char> from input scanner.
  282.     
  283.        3.2 Symbols
  284.     
  285.              Symbol names  may  include  the  characters  'a'-'z',  'A'-'Z',
  286.           '0'-'9', and '_'. The characters '0'-'9' may not be  used  as  the
  287.           first character in the  symbol  name.  Symbol  names  may  be  any
  288.           length, however, only the first 15 characters are significant.
  289.     
  290.              The "char" modifier may be used to declare a symbol as an 8 bit
  291.           wide value, otherwise it is assumed to be 16 bits.
  292.     
  293.                               eg: char input_char;
  294.     
  295.              The "int" modifier may be used to declare a symbol as a 16  bit
  296.           wide value. This is assumed if neither "int" or "char" is given.
  297.     
  298.                                   eg: int abc;
  299.     
  300.              The "unsigned" modifier may be used to declare a symbol  as  an
  301.           unsigned positive only value. Note that unlike some 'C' compilers,
  302.           this modifier may be applied to a character (8 bit) variable.
  303.     
  304.                             eg: unsigned char count;
  305.     MICRO-C C-FLEA Compiler                                          Page: 6
  306.  
  307.  
  308.              The "extern" modifier causes the compiler to be  aware  of  the
  309.           existance and  type  of  a  global  symbol,  but  not  generate  a
  310.           definition for that symbol. This allows the module being  compiled
  311.           to reference a symbol which is defined  in  another  module.  This
  312.           modifier may not be used with local symbols.
  313.     
  314.                             eg: extern char getc();
  315.     
  316.              A  symbol  declared  as  external  may  be  re-declared  as   a
  317.           non-external at a later  point  in  the  code,  in  which  case  a
  318.           definition for it will be generated. This allows  "extern"  to  be
  319.           used to inform the compiler of a function or variable type so that
  320.           it can be referenced  properly  before  that  symbol  is  actually
  321.           defined.
  322.     
  323.              The "static" modifier causes global  symbols  to  be  available
  324.           only in the file where they are defined.  Variables  or  functions
  325.           declared  as  "static"  will  not  be   accessable   as   "extern"
  326.           declarations in other object files, nor will they cause  conflicts
  327.           with duplicate names in those files.
  328.     
  329.                          eg: static int variable_name;
  330.     
  331.              When applied to local symbols,  the  "static"  modifier  causes
  332.           those variables to be allocated in  a  reserved  area  of  memory,
  333.           instead of on the processor stack. This has the  effect  that  the
  334.           contents of the variable will be retained  between  calls  to  the
  335.           function. It also means that the variable  may  be  initialzed  at
  336.           compile time.
  337.     
  338.              The "register" modifier indicates to the  code  generator  that
  339.           this is a high priority variable, and should be kept where  it  is
  340.           easy to get at. Since  its  interpretation  depends  on  the  code
  341.           generator, it is often  ignored  in  simple  implementations.  See
  342.           "Functions" for a  special  use  of  "register"  when  defining  a
  343.           function.
  344.     
  345.                           eg: register unsigned count;
  346.     
  347.              Symbols declared with a preceeding '*' are assumed to be 16 bit
  348.           pointers to the declared type.
  349.     
  350.                              eg: int *pointer_name;
  351.     
  352.              Symbol names declared followed by square brackets  are  assumed
  353.           to be arrays with a number of dimensions equal to  the  number  of
  354.           '[]' pairs that follow. The size of each dimension  is  identified
  355.           by a constant value  contained  within  the  corresponding  square
  356.           brackets.
  357.     
  358.                           eg: char array_name[5][10];
  359.     MICRO-C C-FLEA Compiler                                          Page: 7
  360.  
  361.  
  362.           3.2.1 Global Symbols
  363.     
  364.                 Symbols  declared  outside  of  a  function  definition  are
  365.              considered to  be  global  and  will  have  memory  permanently
  366.              reserved for them. Global symbols are defined by  name  in  the
  367.              output file, allowing other modules to access them.
  368.     
  369.                 Note that the compiler IS case  sensitive,  however  if  the
  370.              assembler you are using is NOT, you  must  be  careful  not  to
  371.              declare any global symbols with names that differ only in case.
  372.     
  373.                 All non-initialized global variables are  generated  at  the
  374.              very end of the output file, after the literal pool is  dumped.
  375.              Since non-initialized globals do not generate object code, this
  376.              allows them to be excluded from the image file when it is saved
  377.              to disk.
  378.     
  379.                 Global variables may be initialized with one or more values,
  380.              which are expressed as a single array of  integers  REGUARDLESS
  381.              of the size and shape of the variable. If more than  one  value
  382.              is expressed, '{' and '}' must be used.
  383.     
  384.                    eg: int i = 10, j[2][2] = { 1, 2, 3, 4 };
  385.     
  386.                 When arrays are declared, a null dimension may  be  used  as
  387.              the dimension size, in which case the size of  the  array  will
  388.              default to the number of initialized values.
  389.     
  390.                          eg: int array[] = { 1, 2, 3 };
  391.     
  392.                 Initialized global variables are automatically saved  within
  393.              the code image,  insuring  that  the  initial  values  will  be
  394.              available at run time. Any non-initialized elements of an array
  395.              which has been partly initialized will be set to zero.
  396.     
  397.                 Non-initialized global variables are not preset in any  way,
  398.              and will be undefined at the beginning of program execution.
  399.     
  400.           3.2.2 Local Symbols
  401.     
  402.                 Symbols declared within a function definition are  allocated
  403.              on the stack, and  exist  only  during  the  execution  of  the
  404.              function.
  405.     
  406.                 To simplify the allocation and de-allocation of stack space,
  407.              all local symbols must be declared  at  the  beginning  of  the
  408.              function before any code producing statements are encountered.
  409.     
  410.                 MICRO-C does not support initialization of non-static  local
  411.              variables in the declaration statement. Since  local  variables
  412.              have to be initialized every time the function is entered,  you
  413.              can get the same effect  using  assignment  statements  at  the
  414.              beginning of the function.
  415.     
  416.                 No type is assumed for  arguments  to  functions.  Arguments
  417.              must be explicitly declared, otherwise they will  be  undefined
  418.              within the scope of the function definition.
  419.     MICRO-C C-FLEA Compiler                                          Page: 8
  420.  
  421.  
  422.           3.2.3 More Symbol Examples
  423.     
  424.             /* Global variables are defined outside of any function */
  425.             char a;                     /* 8 bit signed */
  426.             unsigned char b;            /* 8 bit unsigned */
  427.             int c;                      /* 16 bit signed */
  428.             unsigned int d;             /* 16 bit unsigned */
  429.             unsigned e;                 /* also 16 bit unsigned */
  430.             extern char f();            /* external function returning char */
  431.             static int g;               /* 16 bit signed, local to file */
  432.             int h[2] = { 1, 2 };        /* initialized array (2 ints) */
  433.     
  434.             main(a, b)                  /* "int" function containing code */
  435.             /* Function arguments are defined between function name and body */
  436.                 int a;                  /* 16 bit signed */
  437.                 unsigned char *b;       /* pointer to 8 bit unsigned */
  438.             {
  439.             /* Local variables are defined inside the function body */
  440.             /* Note that in MICRO-C, only "static" locals can be initialized */
  441.                 unsigned c;             /* 16 bit unsigned */
  442.                 static char d[5];       /* 8 bit signed, reserved in memory */
  443.                 static int e = 1;       /* 16 bit signed, initial value is 1 */
  444.             /* Function code goes here ... */
  445.                 c = 0;                  /* Initialize 'c' to zero */
  446.                 strcpy(d, "Name");      /* Initialize 'd' to "name" */
  447.             }
  448.     MICRO-C C-FLEA Compiler                                          Page: 9
  449.  
  450.  
  451.        3.3 Arrays & Pointers
  452.     
  453.              When MICRO-C passes an array to a function, it actually  passes
  454.           a POINTER to the array. References to arrays which  are  arguments
  455.           are automatically performed through the pointer.
  456.     
  457.              This allows the use of pointers and arrays to be interchangable
  458.           through the context of a function call. Ie: An array passed  to  a
  459.           function may be declared and used as  a  pointer,  and  a  pointer
  460.           passed to a function may be declared and used as an array.
  461.     
  462.        3.4 Functions
  463.     
  464.              Functions are  essentially  initialized  global  symbols  which
  465.           contain executable code.
  466.     
  467.              MICRO-C accepts  any  valid  value  as  a  function  reference,
  468.           allowing  some  rather  unique  (although  non-standard)  function
  469.           calls.
  470.     
  471.           For example:
  472.     
  473.                 function();     /* call function */
  474.                 variable();     /* call contents of a variable */
  475.                 (*var)();       /* call indirect through variable */
  476.                 (*var[x])();    /* call indirect through indexed array */
  477.                 0x5000();       /* call address 0x5000 */
  478.     
  479.              Since this is a single pass compiler, operands to functions are
  480.           evaluated and pushed on the stack in the order in which  they  are
  481.           encountered, leaving the last operand closest to the  top  of  the
  482.           stack. This is the opposite order from which  many  'C'  compilers
  483.           push operands.
  484.     
  485.              For functions with a fixed number of arguments,  the  order  of
  486.           which operands  are  passed  is  of  no  importance,  because  the
  487.           compiler looks after generating  the  proper  stack  addresses  to
  488.           reference variables.  HOWEVER,  functions  which  use  a  variable
  489.           number of arguments are affected for two reasons:
  490.     
  491.           1) The location of the LAST arguments are known (as fixed  offsets
  492.              from the stack pointer) instead of the FIRST.
  493.     
  494.           2) The symbols defined as arguments  in  the  function  definition
  495.              represent the LAST arguments instead of the FIRST.
  496.     
  497.              If a function is declared as "register", it  serves  a  special
  498.           purpose and causes the accumulator to be loaded with the number of
  499.           arguments passed whenever the function is called. This allows  the
  500.           function to know how many  arguments  were  passed  and  therefore
  501.           determine the location of the first argument.
  502.     MICRO-C C-FLEA Compiler                                          Page: 10
  503.  
  504.  
  505.        3.5 Structures & Unions
  506.     
  507.              Combinations of other variable  types  can  be  organized  into
  508.           STRUCTURES or UNIONS, which allow them  to  be  manipulated  as  a
  509.           single entity.
  510.     
  511.              In a structure, the  individual  items  occur  sequentially  in
  512.           memory, and the total size of the structure  is  the  sum  of  its
  513.           elements. Structures are usually  used  to  create  "records",  in
  514.           which related items are grouped together. An array  of  structures
  515.           is the common method of implementing an "in-memory" database.
  516.     
  517.              A union is similar to a structure, except that  the  individual
  518.           items are overlaid in memory, and the total size of the  union  is
  519.           the size of its largest element. Unions are usually used to  allow
  520.           a single block of memory to be accessed as different 'C'  variable
  521.           types. An example of this would be in handling a message  received
  522.           in memory, in which a "type" byte indicates how the  remainder  of
  523.           the message data should be interpreted.
  524.     
  525.              Here are some example of how structures are  defined  and  used
  526.           (unions are defined and used in an identical manner,  except  that
  527.           the word 'union' is substituted for 'struct'):
  528.     
  529.             /* Create structure named 'data' with 'a,b,c & d' as members */
  530.             struct {
  531.                 int a;
  532.                 int b;
  533.                 char c;
  534.                 char d; } data;
  535.     
  536.             /* Create structure template named 'mystruc'... */
  537.             /* No actual structure variable is defined */
  538.             struct mystruc {
  539.                 int a;
  540.                 int b;
  541.                 char c;
  542.                 char d; };
  543.     
  544.             /* Create structure named 'data' using above template */
  545.             struct mystruc data;
  546.     
  547.             /* Create structure template 'mystruc', AND define a */
  548.             /* structure variable named 'data' */
  549.             struct mystruc {
  550.                 int a;
  551.                 int b;
  552.                 char c;
  553.                 char d; } data;
  554.     MICRO-C C-FLEA Compiler                                          Page: 11
  555.  
  556.  
  557.             /* Create an array of structures, a pointer to a structure */
  558.             /* and an array of pointers to a structure *
  559.             struct mystruct array[10], *pointer, *parray[10];
  560.     
  561.             /* To set value in structure variable/members */
  562.             data.a = 10;            /* Direct access */
  563.             array[1].b = 10;        /* Direct array access */
  564.             pointer->c = 'a';       /* Pointer access */
  565.             parray[2]->d = 'b';     /* Pointer array access */
  566.     
  567.             /* To read value in structure variable/members */
  568.             value = data.a;         /* Direct access */
  569.             value = data[1].b;      /* Direct array access */
  570.             value = pointer->c;     /* Pointer access */
  571.             value = parray[2]->d;   /* Pointer array access */
  572.     
  573.           3.5.1 Notes on MICRO-C structure implementation:
  574.     
  575.                 Structures and Unions as implemented in MICRO-C are  similar
  576.              to the implementation of the original UNIX  'C'  compiler,  and
  577.              are bound by similar limitations, as  well  as  a  few  MICRO-C
  578.              specific ones.  Here  is  a  list  of  major  differences  when
  579.              compared to a modern ANSI compiler:
  580.     
  581.                 All structure and member names MUST  be  unique  within  the
  582.              scope of the definition. A special case  exists,  where  common
  583.              member names may be used in  multiple  structure  templates  if
  584.              they have EXACTLY the same type and offset into the  structure.
  585.              This also saves symbol table memory, since only one copy of the
  586.              member definition is actually kept.
  587.     
  588.                 MICRO-C does NOT pass entire structures to functions on  the
  589.              stack. Like  arrays,  MICRO-C  passes  structures  by  ADDRESS.
  590.              Structure variables which are function arguments  are  accessed
  591.              through pointers. For source code compatibility with  compilers
  592.              which do pass the entire structure, if you declare the argument
  593.              as a direct (non-pointer) structure, the direct ('.')  operator
  594.              is used to dereference it, even though it is actually a pointer
  595.              reference.
  596.     
  597.                 If you  MUST  have  a  local  copy  of  the  structure,  use
  598.              something like:
  599.     
  600.                 func(sptr)
  601.                     struct mystruc *sptr;
  602.                 {
  603.                     struct mystruc data;
  604.                     memcpy(data, sptr, sizeof(data));
  605.                     ...
  606.                 }
  607.     MICRO-C C-FLEA Compiler                                          Page: 12
  608.  
  609.  
  610.                 To obtain the size of a structure from  its  template  name,
  611.              use the 'struct'  keyword  in  conjunction  with  the  'sizeof'
  612.              operator.   In   the   above   example,   you   could   replace
  613.              'sizeof(data)' with 'sizeof(struct mystruc)'.
  614.     
  615.                 To obtain the size of a structure member, you  must  specify
  616.              it in the context of a structure reference with another symbol:
  617.     
  618.               sizeof(variable.member) or sizeof(variable->member)
  619.     
  620.                 NOTE: The current compiler allows almost any symbol  to  the
  621.              left of the '.' or '->' operator in a 'sizeof', however  future
  622.              versions of the compiler may insist on a structure variable  or
  623.              a pointer to structure variable.
  624.     
  625.                 Pointers to structures are internally stored as pointers  to
  626.              'char', and therefore will only increment/decrement by  1  when
  627.              ++/-- is used. To advance a pointer by the size of a structure,
  628.              use:
  629.     
  630.                          ptr += sizeof(struct mystruc)
  631.     
  632.                 The 'struct' and 'union' keywords  are  not  accepted  in  a
  633.              TYPECAST. This is most commonly used to setup a  pointer  to  a
  634.              structure. Since MICRO-C stores its pointers to  structures  as
  635.              pointers to char, you can use (char*) as the typecast, and  get
  636.              the same functionality.
  637.     
  638.                 A structure name by itself (without  '.member')  acts  in  a
  639.              manner similar to a character array name.  With  no  operation,
  640.              the address of the structure is returned. You can also use '[]'
  641.              to access  individual  bytes  in  the  structure  by  indexing,
  642.              although doing so is highly non-portable.
  643.     
  644.                 MICRO-C allows static or global structures to be initialized
  645.              in the declaration, however the initial values are read  as  an
  646.              array of bytes, and are assigned directly to  structure  memory
  647.              without regard for the type or size of its members:
  648.     
  649.                 struct mystruc data = { 0, 1, 0, 2, 3, 4 };
  650.                 /* A=0:1, B=0:2, C=3, D=4 */
  651.     
  652.                 You can use INT and CHAR to switch back  and  forth  between
  653.              word/byte initialization within the value list:
  654.     
  655.                 struct mystruct data = { int 0, 1, char 2, 3 };
  656.                 /* A=0, B=1, C=2, D=3 */
  657.     
  658.                 MICRO-C does not WORD ALIGN structure elements. When using a
  659.              processor which requires word alignment, it is the  programmers
  660.              responsibility to maintain alignment, using filler  bytes  etc.
  661.              when necessary.
  662.     MICRO-C C-FLEA Compiler                                          Page: 13
  663.  
  664.  
  665.        3.6 Control Statements
  666.     
  667.              The following control statements are implemented in MICRO-C:
  668.     
  669.                 if(expression)
  670.                     statement;
  671.     
  672.                 if(expression)
  673.                     statement;
  674.                 else
  675.                     statement;
  676.     
  677.                 while(expression)
  678.                     statement;
  679.     
  680.                 do
  681.                     statement;
  682.                 while expression;
  683.     
  684.                 for(expression; expression; expression)
  685.                     statement;
  686.     
  687.                 return;
  688.     
  689.                 return expression;
  690.     
  691.                 break;
  692.     
  693.                 continue;
  694.     
  695.                 switch(expression) {
  696.                     case constant_expression :
  697.                         statement;
  698.                         ...
  699.                         break;
  700.                     case constant_expression :
  701.                         statement;
  702.                         ...
  703.                         break;
  704.                         .
  705.                         .
  706.                         .
  707.                     default:
  708.                         statement; }
  709.     
  710.                 label: statement;
  711.     
  712.                 goto label;
  713.     
  714.                 asm "...";
  715.     
  716.                 asm {
  717.                     ...
  718.                     }
  719.     MICRO-C C-FLEA Compiler                                          Page: 14
  720.  
  721.  
  722.     3.6.1 Notes on Control Structures
  723.     
  724.         1)  Any "statement" may be a single statement or a compound
  725.             statement enclosed within '{' and '}'.
  726.     
  727.         2)  All three "expression"s in the "for" command are optional.
  728.     
  729.         3)  If a "case" selection does not end with "break;", it will
  730.             "fall through" and execute the following case as well.
  731.     
  732.         4)  Expressions following 'return' and 'do/while' do not have
  733.             to be contained in brackets (although this is permitted).
  734.     
  735.         5)  Label names may preceed any statement, and must be any
  736.             valid symbol name, followed IMMEDIATELY by ':' (No spaces
  737.             are allowed). Labels are considered LOCAL to a function
  738.             definition and will only be accessable within the scope
  739.             of that function.
  740.     
  741.         6)  The 'asm' statement used to implement the inline assembly
  742.             language capability of MICRO-C accepts two forms:
  743.                 asm "...";      <- Assemble single line.
  744.                 asm {           <- Assemble multiple lines.
  745.                     ...
  746.                     }
  747.     MICRO-C C-FLEA Compiler                                          Page: 15
  748.  
  749.  
  750.        3.7 Expression Operators
  751.     
  752.              The following expression operators are implemented in MICRO-C:
  753.     
  754.     3.7.1 Unary Operators
  755.     
  756.         -           - Negate
  757.         ~           - Bitwise Complement
  758.         !           - Logical complement
  759.         ++          - Pre or Post increment
  760.         --          - Pre or post decrement
  761.         *           - Indirection
  762.         &           - Address of
  763.         sizeof      - Size of a object or type
  764.         (type)      - Typecast
  765.     
  766.     3.7.2 Binary Operators
  767.     
  768.         +           - Addition
  769.         -           - Subtraction
  770.         *           - Multiplication
  771.         /           - Division
  772.         %           - Modulus
  773.         &           - Bitwise AND
  774.         |           - Bitwise OR
  775.         ^           - Bitwise EXCLUSIVE OR
  776.         <<          - Shift left
  777.         >>          - Shift right
  778.         ==          - Test for equality
  779.         !=          - Test for inequality
  780.         >           - Test for greater than
  781.         <           - Test for less than
  782.         >=          - Test for greater than or equal to
  783.         <=          - Test for less than or equal to
  784.         &&          - Logical AND
  785.         ||          - Logical OR
  786.         =           - Assignment
  787.         +=          - Add to self assignment
  788.         -=          - Subtract from self assignment
  789.         *=          - Multiply by self assignment
  790.         /=          - Divide by and reassign assignment
  791.         %=          - Modular self assignment
  792.         &=          - AND with self assignment
  793.         |=          - OR with self assignment
  794.         ^=          - EXCLUSIVE OR with self assignment
  795.         <<=         - Shift left self assignment
  796.         >>=         - Shift right self assignment
  797.     MICRO-C C-FLEA Compiler                                          Page: 16
  798.  
  799.  
  800.     NOTES:
  801.     
  802.         1)  The expression "a && b" returns 0 if "a" is zero, otherwise the
  803.             value of "b" is returned. The "b" operand is NOT evaluated if
  804.             "a" is zero.
  805.     
  806.         2)  The expression "a || b" returns the value of "a" if it is not 0,
  807.             otherwise the value of "b" is returned. The "b" operand is NOT
  808.             evaluated if "a" is non-zero.
  809.     
  810.     3.7.3 Other Operators
  811.     
  812.         ;           - Ends a statement.
  813.         ,           - Allows several expressions in one statement.
  814.                     + Separates symbol names in multiple declarations.
  815.                     + Separates constants in multi-value initialization.
  816.                     + Separates operands in function calls.
  817.         ?           - Conditional expression (ternary operator).
  818.         :           - Delimits labels, ends CASE and separates conditionals.
  819.         .           - Access a structure member directly.
  820.         ->          - Access a structure member through a pointer.
  821.         { }         - Defines a BLOCK of statements.
  822.         ( )         - Forces priority in expression, indicates function calls.
  823.         [ ]         - Indexes arrays. If fewer index values are given than the
  824.                       number of dimensions which are defined for the array,
  825.                       the value returned will be a pointer to the appropriate
  826.                       address.
  827.     
  828.                     Eg:
  829.                         char a[5][2];
  830.     
  831.                         a[3] returns address of forth row of two characters.
  832.                         (remember index's start from zero)
  833.     
  834.                         a[3][0] returns the character at index [3][0];
  835.     MICRO-C C-FLEA Compiler                                          Page: 17
  836.  
  837.  
  838.        3.8 Inline Assembly Language
  839.     
  840.              Although 'C' is a powerful and  flexible  language,  there  are
  841.           sometimes instances where a particular operation must be  peformed
  842.           at the assembly language level. This most  often  involves  either
  843.           some processor feature for which there  is  no  corresponding  'C'
  844.           operation, or a section of very time critical code.
  845.     
  846.              MICRO-C provides access to assembly  language  with  the  'asm'
  847.           statement, which has two basic forms. The first is:
  848.     
  849.                                   asm "..." ;
  850.     
  851.              In this form, the entire  text  contained  between  the  double
  852.           quote characters (") is output as a single line to the  assembler.
  853.           Note that a  semicolon  is  required,  just  like  any  other  'C'
  854.           statement.
  855.     
  856.              Since this is a standard 'C' string, you can  use  any  of  the
  857.           "special" characters, and thus you could output multiple lines  by
  858.           using '\n' within the string. Another important characteristic  of
  859.           it being a string is that it will be protected from  pre-processor
  860.           substitution.
  861.     
  862.              The second form of the 'asm' statement is:
  863.     
  864.                                      asm {
  865.                                       ...
  866.                                        }
  867.     
  868.              In this form, all lines between '{' and '}' are output  to  the
  869.           assembler. Any text following the opening '{' (on the  same  line)
  870.           is ignored. Due to  the  unknown  characteristics  of  the  inline
  871.           assembly code, the closing '}' will only be recognized when it  is
  872.           the first non-whitespace character on a line.
  873.     
  874.              The integral pre-processor will not perform substitution on the
  875.           inline assembly code, however  the  external  pre-processor  (MCP)
  876.           will substitute in this form. This allows you to  create  assembly
  877.           language "macros" using MCP, and have parameters substituted  into
  878.           them when they are expanded:
  879.     
  880.             /*
  881.              * This macro issues a 'SETB' instruction for its parameter
  882.              */
  883.             #define setbit(bit) asm {\
  884.                 SETB bit\
  885.             }
  886.     
  887.             /*
  888.              * This macro WILL NOT WORK, since the 'bit' operand to the SETB
  889.              * instruction is contained within a string and is therefore
  890.              * protected from substitution by the pre-processor
  891.              */
  892.             #define setbit(bit) asm " SETB bit";
  893.     MICRO-C C-FLEA Compiler                                          Page: 18
  894.  
  895.  
  896.        3.9 Preprocessor Commands
  897.     
  898.              The  MICRO-C  compiler  supports  the  following  pre-processor
  899.           commands. These commands are recognized only if they occur at  the
  900.           beginning of the input line.
  901.     
  902.              NOTE:  This  describes  the  limited  pre-processor  which   is
  903.           integral to the  compiler,  see  also  the  section  on  the  more
  904.           powerful external processor (MCP).
  905.     
  906.           3.9.1 #define <name> <replacement_text>
  907.     
  908.                 The "#define" command allows a global name  to  be  defined,
  909.              which will be replaced with the indicated text whenever  it  is
  910.              encountered in the input file. This occurs prior to  processing
  911.              by the compiler.
  912.     
  913.           3.9.2 #file <filename>
  914.     
  915.                 Sets the filename of the currently  procssing  file  to  the
  916.              given  string.  This  command   is   used   by   the   external
  917.              pre-processor (MCP) to insure that error messages indicate  the
  918.              original source file.
  919.     
  920.           3.9.3 #include <filename>
  921.     
  922.                 This command causes the indicated file to be opened and read
  923.              in as the source  text.  When  the  end  of  the  new  file  is
  924.              encountered, processing will continue with the  line  following
  925.              "#include" in the original file.
  926.     
  927.           3.9.4 #ifdef <name>
  928.     
  929.                 Processes the following lines (up to #else or  #endif)  only
  930.              if the given name is defined.
  931.     
  932.           3.9.5 #ifndef <name>
  933.     
  934.                 Processes the following lines (up to #else or  #endif)  only
  935.              if the given name is NOT defined.
  936.     
  937.           3.9.6 #else
  938.     
  939.                 Processes the following lines (up to  #endif)  only  if  the
  940.              preceeding #ifdef or #ifndef was false.
  941.     
  942.           3.9.7 #endif
  943.     
  944.                 Terminates #ifdef and #ifndef
  945.     
  946.                 NOTE: The integral pre-processor does not support nesting of
  947.              the #ifdef and #idndef constructs. If you wish  to  nest  these
  948.              conditionals, you must use the external pre-processor (MCP).
  949.     MICRO-C C-FLEA Compiler                                          Page: 19
  950.  
  951.  
  952.        3.10 Error Messages
  953.     
  954.              When MICRO-C detects an  error,  it  outputs  an  informational
  955.           message indicating the type of problem encountered.
  956.     
  957.              The error message is preceeded by the filename and line  number
  958.           where the error occured:
  959.     
  960.                            program.c(5): Syntax error
  961.     
  962.              In the above example, the error occured in the file "program.c"
  963.           at line 5.
  964.     
  965.              The following error messages are produced by the compiler:
  966.     
  967.           3.10.1 Compilation aborted
  968.     
  969.                 The preceeding error was so severe than the compiler  cannot
  970.              proceed.
  971.     
  972.           3.10.2 Constant expression required
  973.     
  974.                 The compiler requires a constant  expression  which  can  be
  975.              evaluated at compile time (ie: no variables).
  976.     
  977.           3.10.3 Declaration must preceed code.
  978.     
  979.                 All local variables must be defined at the beginning of  the
  980.              function, before any code producing statements are processed.
  981.     
  982.           3.10.4 Dimension table exhausted
  983.     
  984.                 The compiler has encountered more  active  array  dimensions
  985.              than it can handle.
  986.     
  987.           3.10.5 Duplicate local: 'name'
  988.     
  989.                 You have declared the named  local  symbol  more  than  once
  990.              within the same function definition.
  991.     
  992.           3.10.6 Duplicate global: 'name'
  993.     
  994.                 You have declared the named global symbol more than once.
  995.     
  996.           3.10.7 Expected '<token>'
  997.     
  998.                 The compiler  was  expecting  the  given  token,  but  found
  999.              something else.
  1000.     
  1001.           3.10.8 Expression stack overflow
  1002.     
  1003.                 The compiler has found a more complicated expression than it
  1004.              can handle. Check that it is of  correct  syntax,  and  if  so,
  1005.              break it up into two simpler expressions.
  1006.     MICRO-C C-FLEA Compiler                                          Page: 20
  1007.  
  1008.  
  1009.           3.10.9 Expression stack underflow
  1010.     
  1011.                 The compiler has made an error in  parsing  the  expression.
  1012.              Check that it is of correct syntax.
  1013.     
  1014.           3.10.10 Illegal indirection
  1015.     
  1016.                 You have attempted to perform an indirect operation ('*'  or
  1017.              '[]') on an entity which is not a pointer or array. This  error
  1018.              will also result if you attempt to index  an  array  with  more
  1019.              indices than it has dimensions.
  1020.     
  1021.           3.10.11 Illegal initialization
  1022.     
  1023.                 Local variables may not be initialized  in  the  declaration
  1024.              statement. Use assignments at the  beginning  of  the  function
  1025.              code to perform the initialization.
  1026.     
  1027.           3.10.12 Illegal nested function
  1028.     
  1029.                 You may not declare a  function  within  the  definition  of
  1030.              another function.
  1031.     
  1032.           3.10.13 Improper type of symbol: 'name'
  1033.     
  1034.                 The named  symbol  is  not  of  the  correct  type  for  the
  1035.              operation that you are attempting. Eg: 'goto' where the  symbol
  1036.              is not a label.
  1037.     
  1038.           3.10.14 Improper #else/#endif
  1039.     
  1040.                 A #else or #endif statement is out of place.
  1041.     
  1042.           3.10.15 Inconsistant member offset: 'name'
  1043.     
  1044.                 The named structure member is multiply defined,  and  has  a
  1045.              different offset from its first definition.
  1046.     
  1047.           3.10.16 Inconsistant member type: 'name'
  1048.     
  1049.                 The named structure member is multiply defined,  and  has  a
  1050.              different type from its first definition.
  1051.     
  1052.           3.10.17 Inconsistant re-declaration: 'name'
  1053.     
  1054.                 You have attempted to redefine  the  named  external  symbol
  1055.              with a type which does not match its previously declared type.
  1056.     
  1057.           3.10.18 Incorrect declaration
  1058.     
  1059.                 A statement occuring outside of a function definition is not
  1060.              a valid declaration for a function or global variable.
  1061.     MICRO-C C-FLEA Compiler                                          Page: 21
  1062.  
  1063.  
  1064.           3.10.19 Invalid '&' operation
  1065.     
  1066.                 You have attempted to reference  the  address  of  something
  1067.              that has no address. This error also occurs when you attempt to
  1068.              take the address of an array without giving it a  full  set  of
  1069.              indicies. Since the address is already returned in  this  case,
  1070.              simply drop the '&'. (The error occurs because you  are  trying
  1071.              to take the address of an address).
  1072.     
  1073.           3.10.20 Macro expansion too deep
  1074.     
  1075.                 The compiler has encountered a nested macro reference  which
  1076.              is too deep to be resolved.
  1077.     
  1078.           3.10.21 Macro space exhausted
  1079.     
  1080.                 The compiler has encountered  more  macro  ("#define")  text
  1081.              than it has room to store.
  1082.     
  1083.           3.10.22 No active loop
  1084.     
  1085.                 A "continue" or "break" statement was  encountered  when  no
  1086.              loop is active.
  1087.     
  1088.           3.10.23 No active switch
  1089.     
  1090.                 A "case" or "default"  statement  was  encountered  when  no
  1091.              "switch" statement is active.
  1092.     
  1093.           3.10.24 Not an argument: 'name'
  1094.     
  1095.                 You have declared the named variable as an argument, but  it
  1096.              does not appear in the argument list.
  1097.     
  1098.           3.10.25 Non-assignable
  1099.     
  1100.                 You have attempted an operation which results in  assignment
  1101.              of a value to an entity which cannot be assigned. (eg: 1 = 2);
  1102.     
  1103.           3.10.26 Numeric constant required
  1104.     
  1105.                 The compiler requires a constant expression which returns  a
  1106.              simple numeric value.
  1107.     
  1108.           3.10.27 String space exhausted
  1109.     
  1110.                 The compiler has encountered more literal  strings  than  it
  1111.              has room store.
  1112.     
  1113.           3.10.28 Symbol table full
  1114.     
  1115.                 The compiler has encountered more symbol definitions than it
  1116.              can handle.
  1117.     MICRO-C C-FLEA Compiler                                          Page: 22
  1118.  
  1119.  
  1120.           3.10.29 Syntax error
  1121.     
  1122.                 The statement shown does not follow syntax rules and  cannot
  1123.              be parsed.
  1124.     
  1125.           3.10.30 Too many active cases
  1126.     
  1127.                 The compiler has run out of space  for  storing  switch/case
  1128.              tables. Reduce the number of active "cases".
  1129.     
  1130.           3.10.31 Too many defines
  1131.     
  1132.                 The compiler has encountered more '#define' statements  than
  1133.              it can handle. Reduce the number of #defines.
  1134.     
  1135.           3.10.32 Too many errors
  1136.     
  1137.                 The compiler is aborting because of excessive errors.
  1138.     
  1139.           3.10.33 Too many includes
  1140.     
  1141.                 The compiler has encountered more  nested  "#include"  files
  1142.              than it can handle.
  1143.     
  1144.           3.10.34 Too many initializers
  1145.     
  1146.                 You have specified more initialization values than there are
  1147.              locations in the global variable.
  1148.     
  1149.           3.10.35 Type clash
  1150.     
  1151.                 You have attempted to use a  value  in  a  manner  which  is
  1152.              inconsistant with its typing information.
  1153.     
  1154.           3.10.36 Unable to open: 'name'
  1155.     
  1156.                 A "#include" command specified the named file,  which  could
  1157.              not be opened.
  1158.     
  1159.           3.10.37 Undefined: 'name'
  1160.     
  1161.                 You have referenced a name which is not defined as  a  local
  1162.              or global symbol.
  1163.     
  1164.           3.10.38 Unknown structure/member: 'name'
  1165.     
  1166.                 You have referenced a  structure  template  or  member  name
  1167.              which is not defined.
  1168.     
  1169.           3.10.39 Unreferenced: 'name'
  1170.     
  1171.                 The named  symbol  was  defined  as  a  local  symbol  in  a
  1172.              function, but was never used in that function. This error  will
  1173.              occur at the end of  the  function  definition  containing  the
  1174.              symbol declaration. It is only a warning, and  will  not  cause
  1175.              the compile to abort.
  1176.     MICRO-C C-FLEA Compiler                                          Page: 23
  1177.  
  1178.  
  1179.           3.10.40 Unresolved: 'name'
  1180.     
  1181.                 The named symbol was forward  referenced  (Such  as  a  GOTO
  1182.              label), and was never defined. This error will occur at the end
  1183.              of the function definition containing the reference.
  1184.     
  1185.           3.10.41 Unterminated conditional
  1186.     
  1187.                 The end of file was encountered  when  a  "#if"  or  "#else"
  1188.              conditional block was being processed.
  1189.     
  1190.           3.10.42 Unterminated function
  1191.     
  1192.                 The  end  of  the  file  was  encountered  when  a  function
  1193.              definition was still open.
  1194.     MICRO-C C-FLEA Compiler                                          Page: 24
  1195.  
  1196.  
  1197.        3.11 Quirks
  1198.     
  1199.              Due  to  its  background  as  a  highly  compact  and  portable
  1200.           compiler, and its target application in embedded systems,  MICRO-C
  1201.           deviates from standard 'C' in  some  areas.  The  following  is  a
  1202.           summary of the major infractions and quirks:
  1203.     
  1204.              When using the INTERNAL  pre-processor,  the  operands  to  '#'
  1205.           commands are parsed based on separating spaces, and any portion of
  1206.           the line not required is ignored.  In  particular,  the  '#define'
  1207.           command only accepts a definition up to  the  next  space  or  tab
  1208.           character.
  1209.     
  1210.             eg: #define APLUSONE A+1        <-- uses "A+1"
  1211.                 #define APLUSONE A +1       <-- uses "A"
  1212.     
  1213.              Comments are stripped by the token scanner, which occurs  AFTER
  1214.           the '#' commands are processed.
  1215.     
  1216.             eg: #define NULL    /* comment */   <-- uses "/*"
  1217.     
  1218.              Note that since comments can therefore be included in "#define"
  1219.           symbols, you can use "/**/" to simulate spaces between tokens.
  1220.     
  1221.             eg: #define BYTE unsigned/**/char
  1222.     
  1223.              Include filenames are not delimited by '""'  or  '<>'  and  are
  1224.           passed to the operating system exactly as entered.
  1225.     
  1226.             eg: #include \mc\stdio.h
  1227.     
  1228.              NOTE:  The  above  quirks  DO  NOT  APPLY  when  the   EXTERNAL
  1229.           pre-processor (MCP) is used.
  1230.     
  1231.              The appearance of a variable name in the argument  list  for  a
  1232.           function  declaration  serves  only  to  identify  that  variables
  1233.           location on the stack. MICRO-C will not define the variable unless
  1234.           it is explicitly declared (between the argument list and the  main
  1235.           function body). In other words, all arguments to a  function  must
  1236.           be explicitly declared.
  1237.     
  1238.              MICRO-C is more  strict  about  its  handling  of  the  ADDRESS
  1239.           operator ('&') than most other compilers. It will produce an error
  1240.           message if you attempt to take the address of  a  value  which  is
  1241.           already a fixed address (such as an array name without a full  set
  1242.           of indicies). Since an address is already produced in such  cases,
  1243.           simply drop the '&'.
  1244.     
  1245.              The 'x' in '0x' and '\x' is accepted in lower case only.
  1246.     MICRO-C C-FLEA Compiler                                          Page: 25
  1247.  
  1248.  
  1249.              When operating on pointers, MICRO-C only scales  the  increment
  1250.           (++), decrement (--) and index ([]) operations to account for  the
  1251.           size of the pointer:
  1252.     
  1253.             eg: char *cptr;     /* pointer to character */
  1254.                 int  *iptr;     /* pointer to integer */
  1255.                 ++cptr;         /* Advance one character */
  1256.                 ++iptr;         /* Advance one integer */
  1257.                 cptr[10];       /* Access the tenth character */
  1258.                 iptr[10];       /* Access the tenth integer */
  1259.                 cptr += 10;     /* Advance 10 characters */
  1260.                 iptr += 10;     /* Advance ONLY FIVE integers */
  1261.     
  1262.             NOTE: A portable way to advance "iptr" by integers is:
  1263.     
  1264.                 iptr = &iptr[10];   /* Advance 10 integers */
  1265.     
  1266.              Since  structures  are  internally  represented  as  arrays  of
  1267.           "char", incrementing a pointer to a structure  will  advance  only
  1268.           one (1) byte in memory. To advance to the "next" instance  of  the
  1269.           structure, use:
  1270.     
  1271.                         ptr += sizeof(struct template);
  1272.     
  1273.              The INDEXING operator '[]' is not commutative  in  MICRO-C.  In
  1274.           other words 'array[index]' cannot be expressed as 'index[array]'.
  1275.     
  1276.              MICRO-C does  not  support  "complex"  declarations  which  use
  1277.           brackets '()' for other than function parameters. These  are  most
  1278.           often used in establishing pointers to functions:
  1279.                     int (*a)();     /* Pointer to function returning INT */
  1280.                     (*a)();         /* Call address in 'a' */
  1281.     
  1282.              Since MICRO-C allows you to call any value by following it with
  1283.           '()', you can get  the  desired  effect  in  the  above  case,  by
  1284.           declaring 'a' as a simple pointer to int, and calling it with  the
  1285.           same syntax:
  1286.                     int *a;         /* Pointer to INT */
  1287.                     (*a)();         /* Call address in 'a' */
  1288.     
  1289.              MICRO-C will not output external  declarations  to  the  output
  1290.           file  for  any  variables  or  functions  which  are  declared  as
  1291.           "extern", unless that symbol is actually  referenced  in  the  'C'
  1292.           source code. This prevents "extern" declarations in system  header
  1293.           files (such as "stdio.h") which are used as  prototypes  for  some
  1294.           library functions from causing those functions to be  loaded  into
  1295.           the  object  file.  Therefore,  any  "extern"  symbols  which  are
  1296.           referenced only by inline assembly code must be  declared  in  the
  1297.           assembly code, not by the MICRO-C "extern" statement.
  1298.     MICRO-C C-FLEA Compiler                                          Page: 26
  1299.  
  1300.  
  1301.              Unlike some  'C'  compilers,  MICRO-C  will  process  character
  1302.           expressions using only  BYTE  values.  Character  values  are  not
  1303.           promoted to INT unless there is  an  INT  value  involved  in  the
  1304.           expression. This results in much more efficent code  when  dealing
  1305.           with characters, particularily  on  small  processors  which  have
  1306.           limited 16 bit instructions. Consider the statement:
  1307.     
  1308.                                  return c + 1;
  1309.     
  1310.              On some compilers, this will sign extend the character variable
  1311.           'c' into an integer value, and then ADD an integer  1  and  return
  1312.           the  result.  MICRO-C  will  ADD  the  character  variable  and  a
  1313.           character 1, and then promote the result to INT  before  returning
  1314.           it (results of expressions as  operands  to  'return'  are  always
  1315.           promoted to int).
  1316.     
  1317.              Unfortunately, programs have been written  which  rely  on  the
  1318.           automatic promotion of characters to INTs to  work  properly.  The
  1319.           most common source of problems is code  which  attempts  to  treat
  1320.           CHAR variables as UNSIGNED values (many older  compilers  did  not
  1321.           support UNSIGNED CHAR). For example:
  1322.     
  1323.                                 return c & 255;
  1324.     
  1325.              In a compiler which always evaluates character  expressions  as
  1326.           INT, the above statement will extract the value of 'c' as positive
  1327.           integer ranging from 0 to 255.
  1328.     
  1329.              In MICRO-C, ANDing a character with 255  results  in  the  same
  1330.           character, which gets promoted to an integer  value  ranging  from
  1331.           -128 to 127. To force the promotion  within  the  expression,  you
  1332.           could CAST the variable to an INT:
  1333.     
  1334.                               return (int)c & 255;
  1335.     
  1336.              The same objective can be achieved  in  a  more  efficent  (and
  1337.           correct) manner by declaring the variable 'c' as UNSIGNED CHAR, or
  1338.           by CASTing the variable to an UNSIGNED value:
  1339.     
  1340.                               return (unsigned)c;
  1341.     
  1342.              Note that this is not only more clearly shows the intent of the
  1343.           programmer, but also results is more efficent code generated.
  1344.     MICRO-C C-FLEA Compiler                                          Page: 27
  1345.  
  1346.  
  1347.              A related quirk arises because most processors do not support a
  1348.           simple efficent method for adding or subtracting a  SIGNED  8  bit
  1349.           quantity and a 16 bit quantity. The code generators supplied  with
  1350.           MICRO-C make the assumption that character values being  added  or
  1351.           subtracted to/from integers will contain only POSITIVE values, and
  1352.           thus use UNSIGNED  addition/subtraction.  This  allows  much  more
  1353.           efficent code to be generated, as the carry/borrow  from  the  low
  1354.           order byte of the operation is simply propagated to the high order
  1355.           byte of the result (an operation  supported  in  hardware  by  the
  1356.           CPU).
  1357.     
  1358.              For those rare instances where you do wish  to  add/subtract  a
  1359.           potentially negative character value to/from an int, you can force
  1360.           the expression to be performed  in  less  efficent  fully  16  bit
  1361.           arithmetic by casting the character to an int.
  1362.     
  1363.                 int i;
  1364.                 char c;
  1365.                 ...
  1366.                 i += c;         /* Very efficent... C should be positive */
  1367.                 i += (int)c;    /* Less efficent... C can be negative */
  1368.     
  1369.              Read the notes at the end of the section  entitled  "Structures
  1370.           and Unions" for information on  limitations  or  differences  from
  1371.           standard 'C' in MICRO-C's implementation of structures and unions.
  1372.     MICRO-C C-FLEA Compiler                                          Page: 28
  1373.  
  1374.  
  1375.     4. ADVANCED TOPICS
  1376.     
  1377.           This section provides information on the more advanced aspects  of
  1378.        MICRO-C, which  is  generally  not  needed  for  casual  use  of  the
  1379.        language.
  1380.     
  1381.        4.1 Conversion Rules
  1382.     
  1383.              MICRO-C keep track of the "type" of  each  value  used  in  all
  1384.           expressions. This type identifies certain characteristics  of  the
  1385.           value,  such  as   size   range   (8/16   bits),   numeric   scope
  1386.           (signed/unsigned), reference (value/pointer) etc.
  1387.     
  1388.              When an  operation  is  performed  on  two  values  which  have
  1389.           identical "types", MICRO-C assigns that same "type" to the result.
  1390.     
  1391.              When the  two  value  "types"  involved  in  an  operation  are
  1392.           different, MICRO-C calculates the "type" of the result  using  the
  1393.           following rules:
  1394.     
  1395.           4.1.1 Size range
  1396.     
  1397.                 If both values are  direct  (not  pointer)  references,  the
  1398.              result will be 8 bits only if  both  values  were  8  bits.  If
  1399.              either value was 16 bits, the result will be 16 bits.
  1400.     
  1401.                 If one value is a pointer, and  the  other  is  direct,  the
  1402.              result will be a pointer to the same size value as the original
  1403.              pointer.
  1404.     
  1405.                 If both values were pointers, the result will be  a  pointer
  1406.              to 16 bits only if both original  pointers  referenced  16  bit
  1407.              values. If either pointer referenced an 8 bit value, the result
  1408.              will reference an 8 bit value.
  1409.     
  1410.           4.1.2 Numeric Scope
  1411.     
  1412.                 The result of an expression is considered to be signed  only
  1413.              if both original values were signed. If  either  value  was  an
  1414.              unsigned value, the result is unsigned.
  1415.     
  1416.           4.1.3 Reference
  1417.     
  1418.                 If either of the original values was a pointer,  the  result
  1419.              will be a pointer.
  1420.     
  1421.              Note that this "calculated" result type  is  used  for  partial
  1422.           results within an expression. Whenever a symbol such as a variable
  1423.           or function is referenced, the type of that symbol is  taken  from
  1424.           its declaration, no matter what "type" of value  was  last  stored
  1425.           (variable) or returned (function).
  1426.     
  1427.              The TYPECAST  operation  may  be  used  to  override  the  type
  1428.           calculated for the result of an expression if necessary.
  1429.     MICRO-C C-FLEA Compiler                                          Page: 29
  1430.  
  1431.  
  1432.        4.2 Assembly Language Interface
  1433.     
  1434.              Assembly language programs may be called from 'C' functions and
  1435.           vice versa. These programs may be in the form of  inline  assembly
  1436.           language statements in the 'C' source code, or  separately  linked
  1437.           modules.
  1438.     
  1439.              INLINE code may use all virtual processor registers freely.
  1440.     
  1441.              Global variables defined in 'C' exist at absolute addresses and
  1442.           may be referenced directly by name from assembly language.  Global
  1443.           names which are referenced  by  both  assembly  language  and  'C'
  1444.           should not be longer than 15 characters.
  1445.     
  1446.              When MICRO-C calls any routine ('C'  or  assembler),  it  first
  1447.           pushes all arguments to the routine onto the processor  stack,  in
  1448.           the order in  which  they  occur  in  the  argument  list  to  the
  1449.           function. This means that the LAST argument  to  the  function  is
  1450.           LOWEST on the processor stack.
  1451.     
  1452.              Arguments are always pushed as 16 bit values. Character  values
  1453.           are extended to 16 bits, and arrays are passed as 16 bit  pointers
  1454.           to the array. (MICRO-C knows that arrays which are  arguments  are
  1455.           actually  pointers,  and  automatically  references  through   the
  1456.           pointer).
  1457.     
  1458.              After pushing the arguments, MICRO-C then generates  a  machine
  1459.           language subroutine  call,  thereby  executing  the  code  of  the
  1460.           routine.
  1461.     
  1462.              Once the called routine returns, the arguments are removed from
  1463.           the stack by the calling program.
  1464.     
  1465.              When the called function executes, the first thing usually done
  1466.           is to reserve space on the stack for any local variables which are
  1467.           required.
  1468.     MICRO-C C-FLEA Compiler                                          Page: 30
  1469.  
  1470.  
  1471.              It is the responsibility of the called function to  remove  any
  1472.           saved registers and local variable space from the stack before  it
  1473.           returns. If a value is to be returned to the calling  program,  it
  1474.           is expected to be in the 16 bit ACCUMULATOR.
  1475.     
  1476.              Local variables in a function may be referenced as offsets from
  1477.           the stack pointer. Note that offsets  must  be  adjusted  for  the
  1478.           number of additional bytes which are  pushed  and  popped  on  the
  1479.           stack during the execution of  the  function.  The  address  of  a
  1480.           particular local variable is calculated as:
  1481.     
  1482.                                 "stack pointer"
  1483.                                        +
  1484.                    (# bytes pushed during function execution)
  1485.                                        +
  1486.                (size of all preceeding local variables in bytes)
  1487.     
  1488.              Arguments to a  function  may  also  be  referenced  as  direct
  1489.           offsets from the stack pointer, in much  the  same  way  as  local
  1490.           variables are. The address of a particular argument is  calculated
  1491.           as:
  1492.     
  1493.                                 "stack pointer"
  1494.                                        +
  1495.                    (# bytes pushed during function execution)
  1496.                                        +
  1497.                      (size of all local variables in bytes)
  1498.                                        +
  1499.                      (Size of return address on stack (2))
  1500.                                        +
  1501.                       (# arguments from LAST argument) * 2
  1502.     
  1503.              If a function has been declared  as  "register",  MICRO-C  will
  1504.           load the accumulator with  the  number  of  arguments  which  were
  1505.           passed, each time the function is called. This allows the function
  1506.           to determine the location of the  first  argument,  which  may  be
  1507.           calculated as:
  1508.     
  1509.                                 "stack pointer"
  1510.                                        +
  1511.                            (accumulator contents) * 2
  1512.                                        +
  1513.                    (# bytes pushed during function execution)
  1514.                                        +
  1515.                      (size of all local variables in bytes)
  1516.                                        +
  1517.                      (Size of return address on stack (2))
  1518.     
  1519.              Examine  the  supplied  library  functions,  as  well  as  code
  1520.           produced by the compiler to gain more insight into the  techniques
  1521.           of accessing local variables and arguments.
  1522.     MICRO-C C-FLEA Compiler                                          Page: 31
  1523.  
  1524.  
  1525.        4.3 Compiling for ROM
  1526.     
  1527.              The output from the compiler is entirely "clean",  and  may  be
  1528.           placed in Read Only Memory (ROM).
  1529.     
  1530.              The compiler places all initialized  global  variables  in  the
  1531.           output file as part of the code image. When the program is  stored
  1532.           in ROM, those variables are also stored in ROM, and  will  not  be
  1533.           modifiable.
  1534.     
  1535.              When the program is to be placed in ROM, you may not initialize
  1536.           any variables which you intend to modify  later.  Those  variables
  1537.           must be explicitly initialized by code executed at  the  beginning
  1538.           of the program.
  1539.     
  1540.              Variables which you do not intend to  modify  (such  as  tables
  1541.           etc.)  may  be  initialized  in  the  declaration,  and  will   be
  1542.           permanently saved in the ROM as part of the static code image.
  1543.     
  1544.              The addresses for code and data storage are established by  the
  1545.           startup files in the runtime library, You may examine  and  modify
  1546.           these files to suit your own particular memory allocation needs.
  1547.     MICRO-C C-FLEA Compiler                                          Page: 32
  1548.  
  1549.  
  1550.     5. THE MICRO-C COMPILER
  1551.     
  1552.           The heart of the MICRO-C programming environment is the  COMPILER.
  1553.        This program reads a  file  containing  a  'C'  source  program,  and
  1554.        translates it into an equivalent assembly language program.
  1555.     
  1556.           The compiler includes its  own  limited  pre-processor,  which  is
  1557.        suitable for  compiling  programs  requiring  only  non-parameterized
  1558.        MACRO substitution, simple INCLUDE file capability, and  single-level
  1559.        CONDITIONAL processing.
  1560.     
  1561.        5.1 The MCCCF command
  1562.     
  1563.              The format of the MICRO-C C-FLEA Compiler command line is:
  1564.     
  1565.                    MCCCF [input_file] [output_file] [options]
  1566.     
  1567.              [input_file] is the name of  the  source  file  containing  'C'
  1568.           statements to read. If no filenames are  given,  MCCCF  will  read
  1569.           from standard input.
  1570.     
  1571.              [output_file] is the name of the file to  which  the  generated
  1572.           assembly language code is written. If less than two filenames  are
  1573.           specified, MCCCF will write to standard output.
  1574.     
  1575.           5.1.1 Command Line Options
  1576.     
  1577.                 -c      - Includes the 'C' source code in the output file
  1578.                           as assembly language comments.
  1579.     
  1580.                 -f      - Causes the compiler to "Fold" its literal pool.
  1581.                           (Identical strings not contained in explicit
  1582.                           variables only once in memory).
  1583.     
  1584.                 -l      - Enables MCCCF to accept line numbers.
  1585.                           (At beginning of line, followed by ':').
  1586.     
  1587.                 -q      - Instructs MCCCF to be quiet, and not display the
  1588.                           startup message when it is executed.
  1589.     MICRO-C C-FLEA Compiler                                          Page: 33
  1590.  
  1591.  
  1592.     6. THE MICRO-C PREPROCESSOR
  1593.     
  1594.           The MICRO-C Preprocessor is a source code filter,  which  provides
  1595.        greater capabilities than the preprocessor which is integral  to  the
  1596.        MICRO-C compiler. It has been implemented as a  stand  alone  utility
  1597.        program which processes the source code before it is compiled.
  1598.     
  1599.           Due to the higher complexity of  this  preprocessor,  it  operates
  1600.        slightly slower than the the integral MICRO-C preprocessor.  This  is
  1601.        mainly due to the fact that it reads each line from the file and then
  1602.        copies it to a new line while performing the macro substitution. This
  1603.        is necessary since each macro may contain parameters  which  must  be
  1604.        replaced "on the fly" when it is referenced.
  1605.     
  1606.           The integral MICRO-C preprocessor is very FAST,  because  it  does
  1607.        not copy the input line. When it encounters a '#define'd  symbol,  it
  1608.        simply adjusts the input scanner pointer to point to  the  definition
  1609.        of that symbol.
  1610.     
  1611.           Keeping the extended preprocessor as a stand alone utility  allows
  1612.        you  to  choose  between  greater   MACRO   capability   and   faster
  1613.        compilation. It also allows the system to continue  to  run  on  very
  1614.        small hardware platforms.
  1615.     
  1616.           The additional capabilities of the extended preprocessor are:
  1617.     
  1618.             - Parameterized MACROs.
  1619.     
  1620.             - Multiple line MACRO's.
  1621.     
  1622.             - Nested conditionals.
  1623.     
  1624.             - Ability to undefine MACRO symbols.
  1625.     
  1626.             - Library reference in include file names.
  1627.     MICRO-C C-FLEA Compiler                                          Page: 34
  1628.  
  1629.  
  1630.        6.1 The MCP command
  1631.     
  1632.              The format of the MICRO-C Preprocessor command line is:
  1633.     
  1634.                     MCP [input_file] [output_file] [options]
  1635.     
  1636.              [input_file] is the name of  the  source  file  containing  'C'
  1637.           statements to read. If no filenames are given, MCP will read  from
  1638.           standard input.
  1639.     
  1640.              [output_file] is the name of the file to  which  the  processed
  1641.           source code is written. If less than two filenames are  specified,
  1642.           MCP will write to standard output.
  1643.     
  1644.           6.1.1 Command Line Options
  1645.     
  1646.                 MCP accepts the following command line [options]:
  1647.     
  1648.                 -c      - Instructs MCP to keep comments from  the input
  1649.                           file (except for those in '#' statements which
  1650.                           are always removed). Normally, MCP will remove
  1651.                           all comments.
  1652.     
  1653.                 -l      - Causes the output file to contain line numbers.
  1654.                           Each line in the output file will be  prefixed
  1655.                           with the line number of the  originating  line
  1656.                           from the input file.
  1657.     
  1658.                 l=path  - Defines the directory path which will be taken
  1659.                           to reference  "library"  files when  '<>'  are
  1660.                           used around an  '#include'  file name.  Unless
  1661.                           otherwise specified, the path defaults to:
  1662.                                         '\mc'
  1663.     
  1664.                 -q      - Instructs MCP to be quiet, and not display the
  1665.                           startup message when it is executed.
  1666.     
  1667.           <name>=<text> - Pre-defines a non-parameterized macro  of  the
  1668.                           specified <name> with the string value <text>.
  1669.     MICRO-C C-FLEA Compiler                                          Page: 35
  1670.  
  1671.  
  1672.        6.2 Preprocesor Commands
  1673.     
  1674.              The following commands are recognized by the MCP utility,  only
  1675.           if they occur at the beginning of the source file line:
  1676.     
  1677.           6.2.1 #define <name>(parameters) <replacement text>
  1678.     
  1679.                 Defines a global macro name which will be replaced with  the
  1680.              indicated <replacement text> wherever it occurs in  the  source
  1681.              file.
  1682.     
  1683.                 Macro  names  may  be  any  length,  and  may  contain   the
  1684.              characters 'a'-'z', 'A'-'Z', '0'-'9' and '_'.  Names  must  not
  1685.              begin with the characters '0'-'9'.
  1686.     
  1687.                 If the macro name is IMMEDIATELY followed by a list of up to
  1688.              10 parameter names contained in brackets, those parameter names
  1689.              will be substituted with parameters passed to the macro when it
  1690.              is referenced. Parameter names follow the same rules  as  macro
  1691.              names.
  1692.     
  1693.                      eg: #define min(a, b) (a < b ? a : b)
  1694.     
  1695.                 If any spaces exist between the macro name and  the  opening
  1696.              '(', the macro will not be  parameterized,  and  all  following
  1697.              text (including '(' and ')') will be  entered  into  the  macro
  1698.              definition.
  1699.     
  1700.                 If the very last character of a  macro  definition  line  is
  1701.              '\', MCP will continue the definition with the next  line  (The
  1702.              '\' is not included). Pre-processor statements included as part
  1703.              of a macro definition will not be processed by MCP, but will be
  1704.              passed on and handled by the integral MICRO-C preprocessor.
  1705.     
  1706.           6.2.2 #undef <symbol>
  1707.     
  1708.                 Undefines the named macro symbol. further references to this
  1709.              symbol will not be replaced.
  1710.     
  1711.                 NOTE: With MCP, macro definitions operate on a STACK. IE: If
  1712.              you define a macro  symbol,  and  then  re-define  it  (without
  1713.              '#undef'ing it first), subsequently '#undef'ing it  will  cause
  1714.              it to revert to its  previous  definition.  A  second  '#undef'
  1715.              would then cause it to be completely undefined.
  1716.     MICRO-C C-FLEA Compiler                                          Page: 36
  1717.  
  1718.  
  1719.           6.2.3 #forget <symbol>
  1720.     
  1721.                 Similar  to  '#undef',  except  that  the  symbol  and   ALL
  1722.              SUBSEQUENTLY DEFINED SYMBOLS will be undefined.
  1723.     
  1724.                 Useful for releasing any local symbols (used only  within  a
  1725.              single include file).
  1726.     
  1727.                 For example:
  1728.     
  1729.                         #define GLOBAL "xxx"    /* first global symbol */
  1730.                             ...                 /* more globals */
  1731.                         #define LOCAL   "xxx"   /* first local symbol */
  1732.                             ...                 /* more locals */
  1733.                         /* body of include file goes here */
  1734.                         #forget LOCAL           /* release locals */
  1735.     
  1736.           6.2.4 #ifdef <symbol>
  1737.     
  1738.                 Causes the following lines (up to '#else' of '#endif') to be
  1739.              processed and included in the source file  only  if  the  named
  1740.              symbol is defined as a macro.
  1741.     
  1742.           6.2.5 #ifndef <symbol>
  1743.     
  1744.                 Causes the following lines (up to '#else' of '#endif') to be
  1745.              processed and included in the source file  only  if  the  named
  1746.              symbol is NOT defined as a macro.
  1747.     
  1748.                 NOTE: '#ifdef/#ifndef#else/#endif' may be nested.
  1749.     
  1750.           6.2.6 #else
  1751.     
  1752.                 Toggles the state of the "if_flag", controlling  conditional
  1753.              processing. Only has effect in the highest level  of  suspended
  1754.              processing. IE: Nested conditionals will work properly.
  1755.     
  1756.                 If the previous  '#ifdef/#ifndef'  failed,  processing  will
  1757.              begin again following the '#else'.
  1758.     
  1759.                 If the previous '#ifdef/#ifndef' passed, processing will  be
  1760.              suspended until the '#endif' is encountered.
  1761.     
  1762.                 NOTE: Since '#else' acts as a toggle, it may be used outside
  1763.              of any '#ifdef/#ifndef' to unconditionally  suspend  processing
  1764.              up to '#endif'. You can also use multiple '#else's in a  single
  1765.              conditional,  to  swap  back  and  forth   between   true/false
  1766.              processing without re-testing the condition.
  1767.     
  1768.           6.2.7 #endif
  1769.     
  1770.                 Resets  the  "if_flag"  controlling  conditionals,   causing
  1771.              processing to resume. Only has effect in the highest  level  of
  1772.              suspended  processing.  IE:  Nested  conditionals   will   work
  1773.              properly.
  1774.     MICRO-C C-FLEA Compiler                                          Page: 37
  1775.  
  1776.  
  1777.           6.2.8 #include <filename>
  1778.     
  1779.                 Causes MCP to open the named file and include  its  contents
  1780.              as part of the input source.
  1781.     
  1782.                 If the filename is contained within '"' characters, it  will
  1783.              be opened exactly as  specified,  and  (unless  it  contains  a
  1784.              directory path) will reference a file in the current directory.
  1785.     
  1786.                 If the filename is contained within the characters  '<'  and
  1787.              '>', it will be  prefixed  with  the  library  path  (See  'l='
  1788.              option), and will therefore reference a file  in  that  library
  1789.              directory. The default  library  directory  is  assumed  to  be
  1790.              '\mc'.
  1791.     
  1792.                 For example:
  1793.     
  1794.                         #include "header.h"     /* from current directory */
  1795.                         #include <stdio.h>      /* from library directory */
  1796.     MICRO-C C-FLEA Compiler                                          Page: 38
  1797.  
  1798.  
  1799.        6.3 Error messages
  1800.     
  1801.              When MCP detects an error during processing of an include file,
  1802.           it displays an error message, which is preceeded by  the  filename
  1803.           and line number where the error occurs. If more than 10 errors are
  1804.           encountered, MCP will terminate.
  1805.     
  1806.              The following error messages are reported by MCP:
  1807.     
  1808.           6.3.1 Cannot open include file
  1809.     
  1810.                 A '#include' statement on the  indicated  line  specified  a
  1811.              file which could not be opened for reading.
  1812.     
  1813.           6.3.2 Invalid include file name
  1814.     
  1815.                 A '#include' statement on the  indicated  line  specified  a
  1816.              file  name  which  was  not  contained  within  '"'   or   '<>'
  1817.              characters.
  1818.     
  1819.           6.3.3 Invalid macro name
  1820.     
  1821.                 A '#define' statement on the indicated line contains a macro
  1822.              name which does not follow the name rules.
  1823.     
  1824.           6.3.4 Invalid macro parameter
  1825.     
  1826.                 A '#define' statement on the indicated line contains a macro
  1827.              parameter name which does not follow the name rules.
  1828.     
  1829.                 A reference to a macro does not have a proper ')'  character
  1830.              to terminate the parameter list.
  1831.     
  1832.           6.3.5 Too many errors
  1833.     
  1834.                 More  than  10  errors  has  been  encountered  and  MCP  is
  1835.              terminating.
  1836.     
  1837.           6.3.6 Too many macro definitions
  1838.     
  1839.                 MCP has encountered more '#define' statements  than  it  can
  1840.              handle.
  1841.     
  1842.           6.3.7 Too many macro parameters
  1843.     
  1844.                 A '#define' statement on the indicated line  specifies  more
  1845.              parameters to the macro than MCP can handle.
  1846.     
  1847.           6.3.8 Too many include files
  1848.     
  1849.                 MCP has encountered more nested '#include'  statements  than
  1850.              it can handle.
  1851.     MICRO-C C-FLEA Compiler                                          Page: 39
  1852.  
  1853.  
  1854.           6.3.9 Undefined macro
  1855.     
  1856.                 A '#undef' or '#forget'  statement  on  the  indicated  line
  1857.              references a macro name which has not been defined.
  1858.     
  1859.           6.3.10 Unterminated comment
  1860.     
  1861.                 The END OF FILE has  been  encountered  while  processing  a
  1862.              comment.
  1863.     
  1864.           6.3.11 Unterminated string
  1865.     
  1866.                 A quoted string  on  the  indicated  line  has  no  end.  To
  1867.              continue a string to  the  next  line,  use  '\'  as  the  last
  1868.              character on the line. The '\' will  not  be  included  in  the
  1869.              string.
  1870.     MICRO-C C-FLEA Compiler                                          Page: 40
  1871.  
  1872.  
  1873.     7. THE MICRO-C OPTIMIZER
  1874.     
  1875.           The MICRO-C optimizer is an output code filter which examines  the
  1876.        assembly code produced by the compiler, recognizing known patterns of
  1877.        inefficent code (using the "peephole" technique), and  replaces  them
  1878.        with more optimal code  which  performs  the  same  function.  It  is
  1879.        entirely table driven, allowing it to be modified for  virtually  any
  1880.        processor.
  1881.     
  1882.           Due its many table lookup operations, the  optimizer  may  perform
  1883.        quite slowly when processing a large  file.  For  this  reason,  most
  1884.        people prefer not to optimize during the debugging of a program,  and
  1885.        utilize the optimizer only when creating the final copy.
  1886.     
  1887.        7.1 The MCOCF command
  1888.     
  1889.              The format of the MICRO-C Optimizer command line is:
  1890.     
  1891.                    MCOCF [input_file] [output_file] [options]
  1892.     
  1893.              [input_file] is the name of the source file containing assembly
  1894.           statements to read. If no filenames are  given,  MCOCF  will  read
  1895.           from standard input.
  1896.     
  1897.              [output_file] is the name of the file to  which  the  optimized
  1898.           assembly  code  is  written.  If  less  than  two  filenames   are
  1899.           specified, MCOCF will write to standard output.
  1900.     
  1901.           7.1.1 Command Line Options
  1902.     
  1903.                 MCOCF accepts the following command line [options]:
  1904.     
  1905.                 -d      - Instructs MCOCF to produce a 'debug' display on
  1906.                           standard output showing the  source code  which
  1907.                           it is removing and replacing in the input file.
  1908.                           NOTE: If you do not specify an  explict  output
  1909.                                 file, you will get the  debug  statements
  1910.                                 intermixed with  the  optimized  code  on
  1911.                                 standard output.
  1912.     
  1913.                 -q      - Instructs  MCOCF  to be quiet,  and not display
  1914.                           the startup message when it is executed.
  1915.     MICRO-C C-FLEA Compiler                                          Page: 41
  1916.  
  1917.  
  1918.     8. THE SOURCE LINKER
  1919.     
  1920.           Many small development environments have assemblers which  do  not
  1921.        directly support an object linker. This causes  a  problem  with  'C'
  1922.        development, because the library functions must be  included  in  the
  1923.        source code, with several drawbacks:
  1924.     
  1925.         1)  There is no way to automatically tell which library functions
  1926.             to include, therefore, you must do it manually.
  1927.     
  1928.         2)  'C' library functions must be  re-compiled every  time,  in
  1929.             order to avoid conflict between compiler generated labels.
  1930.     
  1931.           The MICRO-C Source Linker (SLINK) helps overcome  these  problems,
  1932.        by automatically  joining  previously  compiled  (assembly  language)
  1933.        source code from the library  to  your  programs.  Only  those  files
  1934.        containing functions which you  reference  are  joined  (Taking  into
  1935.        consideration functions called  by  the  included  library  functions
  1936.        etc...). As the files  are  joined,  compiler  generated  labels  are
  1937.        adjusted to be unique within each file.
  1938.     
  1939.        8.1 The SLINK Command
  1940.     
  1941.              The format of the SLINK command line is:
  1942.     
  1943.                    SLINK input_file... output_file [options]
  1944.     
  1945.              "input_file" is the name of  the  source  file  containing  the
  1946.           compiler output from your program.  Several  input  files  may  be
  1947.           specified, in which case they will all be processed into a  single
  1948.           output file.
  1949.     
  1950.              "output_file" is the name of  the  file  to  which  the  linked
  1951.           source code is written.
  1952.     MICRO-C C-FLEA Compiler                                          Page: 42
  1953.  
  1954.  
  1955.           8.1.1 Command line options
  1956.     
  1957.                 SLINK accepts the following command line [options]:
  1958.     
  1959.                 ?       - Display command line help summary.
  1960.     
  1961.                 i=name  - Specify name of the External Index File.
  1962.     
  1963.                 -l      - Instructs SLINK to list each library used.
  1964.     
  1965.                 l=path  - Identifies the directory path which will be
  1966.                           taken to reference "library" files. If not
  1967.                           specified, it defaults to: '\mc\slib'
  1968.     
  1969.                 p=char  - Identifies the PREFIX character of compiler
  1970.                           generated symbols. Defaults is '?'.
  1971.     
  1972.                 -q      - Inhibit display of the startup message.
  1973.     
  1974.                 t=string- Prefix to prepend to temporary filenames.
  1975.                           If not specified, default is "$".
  1976.     
  1977.                 -w      - Sort WORD data to beginning of allocated bulk
  1978.                           unitialized storage (See $DD: directive).
  1979.     
  1980.        8.2 Multiple Input Files
  1981.     
  1982.              SLINK accepts multiple input files on  the  command  line,  and
  1983.           processes each file to build the output file. This allows  you  to
  1984.           "link" together several previously compiled (or assembly language)
  1985.           modules into one final program.
  1986.     
  1987.              Any external references  which  are  not  resolvable  from  the
  1988.           library are assumed to be resolved by  one  of  the  input  source
  1989.           files. Since SLINK does not have knowledge of the  public  symbols
  1990.           defined  in  the  input  files,  the  absence  of  an   externally
  1991.           referenced symbol will not be detected  until  the  assembly  step
  1992.           (where it will cause an undefined symbol error).
  1993.     MICRO-C C-FLEA Compiler                                          Page: 43
  1994.  
  1995.  
  1996.        8.3 The External Index File
  1997.     
  1998.              SLINK uses a special file from the library to  determine  which
  1999.           symbols are in which files. This  files  is  called  the  EXTERNAL
  2000.           INDEX FILE, and is  found  in  the  library  directory  (see  'l='
  2001.           option), under the name "EXTINDEX.LIB".
  2002.     
  2003.              This  file  contains  entries  which  cross-reference  external
  2004.           symbols to files. Each entry is as follows:
  2005.     
  2006.             1)  Any lines beginning with '<' contain the names of files
  2007.                 which are to be processed and included at the BEGINNING
  2008.                 of the program (Before your source file). This the best
  2009.                 way to include the startup code and any runtime library
  2010.                 routines which are required  at  all  times,  and  also
  2011.                 provides a method of initializing any segments used.
  2012.                     eg: <6809rl.asm
  2013.     
  2014.             2)  Any lines beginning with '^' contain the names of files
  2015.                 which are to be processed AFTER the program and library
  2016.                 source files, but BEFORE any  uninitialized  data areas
  2017.                 are output. This is the best way to set up the location
  2018.                 and storage class of the uninitialized data  if it does
  2019.                 not immediately follow the executable program code, and
  2020.                 also providing any postamble needed by the segments.
  2021.     
  2022.             3)  Any lines beginning with '>' contain the names of files
  2023.                 which are to be processed at the END  of  the  program,
  2024.                 after all other information is output. This is the best
  2025.                 way to define heap memory storage,  and  to provide any
  2026.                 post-amble needed by the assembler.
  2027.     
  2028.             4)  Any lines beginning with '-' contain the names of files
  2029.                 which are to  be  included  if  any  of  the  following
  2030.                 symbols  (Up to another '<', '^', '>', '-' or '$')  are
  2031.                 referenced.
  2032.                     eg: -printf.asm format.asm fgets.asm fget.asm
  2033.     
  2034.                 NOTE: In most cases, the library functions will contain
  2035.                 indications of any external references that they do, in
  2036.                 which case SLINK will automatically include those files
  2037.                 even of the names are not mentioned on the '-' line. In
  2038.                 the example above, the following would suffice:
  2039.                         -printf.asm
  2040.     
  2041.             5)  The names  of  each  symbol  which  may  be  referenced
  2042.                 externally must follow the '<', '^', '>' or  '-' entry.
  2043.                 Symbols must occur one per line,  with  no  leading  or
  2044.                 trailing spaces.
  2045.                     eg: printf
  2046.                         fprintf
  2047.                         sprintf
  2048.     MICRO-C C-FLEA Compiler                                          Page: 44
  2049.  
  2050.  
  2051.             6)  A line beginning with '$' is used to define the pseudo-
  2052.                 opcode used by SLINK to reserve uninitialized  data  at
  2053.                 the end of the output file.  Only  one  line  beginning
  2054.                 with '$' should be entered into the EXTINDEX.LIB  file.
  2055.                 The remainder of this line, including all  spaces  etc.
  2056.                 is entered between each symbol name,  and  the  decimal
  2057.                 size (in bytes) which is written to the output file.
  2058.                     eg: '$ RMB '    <- Quotes are for clarity
  2059.     
  2060.             A complete example:
  2061.     
  2062.                     -printf.asm
  2063.                     printf
  2064.                     fprintf
  2065.                     sprintf
  2066.                     -scanf.asm
  2067.                     scanf
  2068.                     fscanf
  2069.                     sscanf
  2070.                     <PREFIX.asm
  2071.                     ^MIDDLE.ASM
  2072.                     >SUFFIX.ASM
  2073.                     $ RMB
  2074.     
  2075.             In summary, the output file is written from:
  2076.     
  2077.                 1 - The '<' (prefix) files              *
  2078.                 2 - The program source files            *\
  2079.                 3 - Library files referenced (if any)   * > See note
  2080.                 4 - Segments 1-9 from above ...         */
  2081.                 5 - The '^' (middle) files
  2082.                 6 - Segments 1-9 from middle files      * See note
  2083.                 7 - Uninitialized data definitions      (if any)
  2084.                 8 - The '>' (suffix) files
  2085.                 9 - Segments 1-9 from sufix file(s)     * See note
  2086.     
  2087.             * NOTE: If these files contain multiple segments (see later),
  2088.                     all segments are grouped and written  in  seguential
  2089.                     order. IE: Seg 0 from all files is written, followed
  2090.                     by Seg 1, etc.
  2091.     MICRO-C C-FLEA Compiler                                          Page: 45
  2092.  
  2093.  
  2094.        8.4 Source file information
  2095.     
  2096.           8.4.1 SLINK Directives
  2097.     
  2098.                 SLINK interpretes several "directives" which may be inserted
  2099.              in the  input  source  files  to  control  the  source  linking
  2100.              process. These directives must be on a separate line, beginning
  2101.              in column 1, and must be in  uppercase.  They  are  removed  by
  2102.              SLINK during processing, and thus will not cause conflict  with
  2103.              the normal syntax used by the assembler.
  2104.     
  2105.                                    $SE:<0-9>
  2106.     
  2107.                 The '$SE' directive is used  by  SLINK  to  define  multiple
  2108.              output segments. Up to 10 segments are allowed, with segment  0
  2109.              being the default which  is  selected  when  a  file  is  first
  2110.              encountered.  Other  segments  (1-9)  when  selected  via  this
  2111.              directive are written to temporary files, and re-joined at  the
  2112.              end of processing in  sequential  order.  this  allows  you  to
  2113.              separate sections of the source file (such as initialized data,
  2114.              literal pool etc.) into distinct areas of memory.
  2115.     
  2116.                               $DD:<symbol> <size>
  2117.     
  2118.                 The '$DD' directive is used  to  define  uninitialized  data
  2119.              storage areas, which will be allocated by SLINK between the '^'
  2120.              (middle) and '>' (suffix) files. This allows  you  to  allocate
  2121.              unitialized data outside of the bounds of the executable image,
  2122.              and thus exclude it from being saved to disk. This  action  may
  2123.              be thought  of  as  an  additional  (11'th)  segment  which  is
  2124.              available for uninitialized data only,  and  which  avoids  the
  2125.              temporary file read/write overhead associated with use  of  the
  2126.              other segments. This directive  is  normally  placed  into  the
  2127.              source file by the "def_global" routine  in  the  MICRO-C  code
  2128.              generator.
  2129.     
  2130.                                   $EX:<symbol>
  2131.     
  2132.                 The '$EX' directuve is used by SLINK to identify any symbols
  2133.              which are externally referenced. Whenever a '$EX' directive  is
  2134.              found, SLINK  searches  the  EXTINDX.LIB  file  for  the  named
  2135.              symbol, and marks the corresponding files for inclusion in  the
  2136.              program. This directive is normally placed into the source file
  2137.              by the "def_extern" routine in the MICRO-C code generator.
  2138.     
  2139.                 If you  are  writing  assembly  language  programs  for  the
  2140.              library, be sure to  include  "$SE:<0-9>"  directives  for  any
  2141.              segments you wish to access, "$DD:<symbol>  <size>"  directives
  2142.              for  any  uninitialized  data  you  wish   to   allocate,   and
  2143.              "$EX:<symbol>" directives for any symbols which you  externally
  2144.              reference. If you wish to place an assembly language comment on
  2145.              the same line, make sure it is separated from the remainder  of
  2146.              the directive by at least one space or tab character.
  2147.     MICRO-C C-FLEA Compiler                                          Page: 46
  2148.  
  2149.  
  2150.                 Also, note that '<' (prefix) files may contain "$SE",  "$DD"
  2151.              and "$EX" directives, '^' (middle) files may contain "$SE"  and
  2152.              "$DD" but not "$EX", and '>' (suffix) files may  only  contains
  2153.              "$SE" directives. Basically, the rule is that "$EX"  cannot  be
  2154.              used after the libraries are included and "$DD" cannot be  used
  2155.              after the uninitialized data is output. Since  the  middle  and
  2156.              suffix files  are  ALWAYS  included,  simply  insure  that  all
  2157.              external references and data declarations needed by any of them
  2158.              are performed in the '<' (prefix) file.
  2159.     
  2160.           8.4.2 Compiler generated labels
  2161.     
  2162.                 As it processes each source file, SLINK scans each line  for
  2163.              symbols which consist of the '?' character (See  'p='  option),
  2164.              followed by a number. If it finds such as symbol, it inserts  a
  2165.              two character sequence ranging from 'AA' to  'ZZ'  between  the
  2166.              '?', and the number. This sequence will be incremented for each
  2167.              source file processed,  and  thus  insures  that  the  compiler
  2168.              generated symbols will be unique for each file.
  2169.     
  2170.                 If you  are  writing  assembly  language  programs  for  the
  2171.              library, you must be careful to  avoid  using  identical  local
  2172.              symbols in any of the library files, one way to do this  is  to
  2173.              use symbols which meet the above criteria.
  2174.     
  2175.        8.5 The SCONVERT command
  2176.     
  2177.              SCONVERT is a utility  which  assists  in  converting  existing
  2178.           assembly language  source  files  into  a  format  which  is  more
  2179.           suitable for use by the SLINK. Two main functions are performed:
  2180.     
  2181.           1) All comments are removed, and  all  spacing  is  reduced  to  a
  2182.              single space. This minimizes the size of the  file,  and  helps
  2183.              decrease linkage time.
  2184.     
  2185.           2) All symbols defined in the file which  are  not  identified  as
  2186.              "keep" symbols are converted to resemble the  MICRO-C  compiler
  2187.              generated symbols. This allows  SLINK  to  adjust  them  to  be
  2188.              unique within each source file.
  2189.     
  2190.              The format of the SCONVERT command line is:
  2191.     
  2192.     
  2193.                  SCONVERT [input_file] [output_file] [options]
  2194.     
  2195.              [input_file] is the name of  the  source  file  containing  the
  2196.           original assembly language program.  If  no  filenames  is  given,
  2197.           SCONVERT will read from standard input.
  2198.     
  2199.              [output_file] is the name of the file to  which  the  converted
  2200.           source code is written. If less  that  two  filenames  are  given,
  2201.           SCONVERT will write to standard output.
  2202.     MICRO-C C-FLEA Compiler                                          Page: 47
  2203.  
  2204.  
  2205.           8.5.1 Command line options
  2206.     
  2207.                 SCONVERT accepts the following command line [options]:
  2208.     
  2209.                 ?       - Display command line help summary.
  2210.     
  2211.                 c=char  - Identifies the character used to begin a comment
  2212.                           at the trailing end of a source line. If no 'c='
  2213.                           is defined, SCONVERT will terminate processing at
  2214.                           the first blank or tab which follows the operand
  2215.                           field.
  2216.     
  2217.                 C=char  - Identifies the charcter which indicates a comment
  2218.                           line in the source code. Defaults to '*'.
  2219.     
  2220.                 k=name  - Identifies a symbol name to KEEP. This symbol will
  2221.                           not be converted. Multiple 'k=' are permitted.
  2222.     
  2223.                 K=file  - Identifies a file containing the names of symbols
  2224.                           to KEEP, one per line. Multiple 'K=' are permitted.
  2225.     
  2226.                 p=char  - Identifies the PREFIX character which is to be used
  2227.                           for the converted symbols. Defaults to '?'.
  2228.     
  2229.                 -q      - Instructs SCONVERT to be quiet, and not issue its
  2230.                           startup message.
  2231.     
  2232.                 SCONVERT identifies symbols in the input source file as  any
  2233.              string beginning with 'A-Z', 'a-z', '_' or '?', and  containing
  2234.              these charcters plus the digits '0-9'. If your assembler source
  2235.              files uses any other characters in its symbols, you  must  edit
  2236.              your sources and change the symbols.
  2237.     
  2238.        8.6 The SRENUM command
  2239.     
  2240.              SRENUM  is  a  small  utility  which  re-numbers  the  compiler
  2241.           generated symbols within a assembly language source file. This  is
  2242.           useful if you have made added symbols to the  file  by  hand,  and
  2243.           wish to make it "pretty" before adding it to the library etc.
  2244.     
  2245.              The format of the SRENUM command is:
  2246.     
  2247.                   SRENUM [input_file] [output_file] [options]
  2248.     
  2249.           8.6.1 Command line options
  2250.     
  2251.                 SRENUM accepts the following command line [options]:
  2252.     
  2253.                 ?       - Display command line help summary.
  2254.     
  2255.                 p=char  - Identifies the PREFIX character which is to be used
  2256.                           to recognize compiler generated symbols.
  2257.     
  2258.                 -q      - Instructs SRENUM to be quiet, and not issue its
  2259.                           startup message.
  2260.     MICRO-C C-FLEA Compiler                                          Page: 48
  2261.  
  2262.  
  2263.        8.7 The SINDEX command
  2264.     
  2265.              SINDEX is a utility  which  assists  in  the  creation  of  the
  2266.           EXTINDEX.LIB file used by SLINK. When you run SINDEX, it  examines
  2267.           all of the '.ASM' files in the current  directory,  and  writes  a
  2268.           EXTINDEX.LIB file which contains a '-' type entry for  each  file,
  2269.           and  external  symbol  entries  for  any  labels  which  it  finds
  2270.           conforming to the 'C' naming conventions (Starts with 'a-z', 'A-Z'
  2271.           or '_', and contains only 'a-z', 'A-Z', '0-9' or '_').
  2272.     
  2273.              Once  you  have  run  SINDEX,  you  must  manually   edit   the
  2274.           EXTINDEX.LIB file, and remove any file or symbol entries which you
  2275.           do not wish to have available as external references, as  well  as
  2276.           insert any necessary entries for '<', '^', '>' and '$' commands.
  2277.     
  2278.           8.7.1 Command line options
  2279.     
  2280.                 SINDEX accepts the following command line options:
  2281.     
  2282.                 ?       - Display command line help summary.
  2283.     
  2284.                 i=name  - Specify name for index file to be written.
  2285.                           Dafault is "EXTINDEX.LIB".
  2286.     
  2287.                 You may also instruct SINDEX to search for  a  file  pattern
  2288.              other than '*.ASM' by passing it as a command line parameter.
  2289.     
  2290.                                 eg: SINDEX *.ACF
  2291.     
  2292.        8.8 The SLIB command
  2293.     
  2294.              Once you have constructed your source  library,  you  may  from
  2295.           time to time want to make minor changes to it, either  adding  new
  2296.           functions, or removing old ones ones.
  2297.     
  2298.              You could make such changes simply by editing the  EXTINDEX.LIB
  2299.           file, however you would have to be very  careful  not  to  add  or
  2300.           delete the wrong entry, and you would have to  manually  determine
  2301.           if adding or removing the file would adversly affect the remainder
  2302.           of the library. For example, you could accidently add a  duplicate
  2303.           of another symbol name, or remove a symbol which is referred to by
  2304.           another file.
  2305.     
  2306.              To simplify maintenance of source libraries, you can  make  use
  2307.           of the "Source Librarian", a utility program which  automates  the
  2308.           addition and removal of source files, and automatically reports of
  2309.           any inconsistancies occuring in the source library.
  2310.     
  2311.              To use SLIB, you must first position yourself to the  directory
  2312.           containing the source library. And then  execute  SLIB  using  the
  2313.           command options described later to indicate the action to be taken
  2314.           on the library. If you do  not  specify  any  actions,  SLIB  will
  2315.           simply examine the library and report its size and content.
  2316.     MICRO-C C-FLEA Compiler                                          Page: 49
  2317.  
  2318.  
  2319.              You may use multiple command options in a single  SLIB  command
  2320.           if you wish to add and/or remove more than one file at a time.
  2321.     
  2322.              After  executing  any  command,  SLIB  will   report   on   any
  2323.           inconsistancies which it finds in the library. If any  are  found,
  2324.           and you have used a command which caused changes, SLIB will prompt
  2325.           for permission before writing the updated library file.
  2326.     
  2327.           8.8.1 Command line options
  2328.     
  2329.                 The following options control the action(s)  which  will  be
  2330.              performed by SLIB on the source library index file.
  2331.     
  2332.                 ?       - Display command line help summary.
  2333.     
  2334.                 ?=file  - Display information about named source file.
  2335.     
  2336.                 a=file  - Add specified file as standard functions.
  2337.     
  2338.                 i=index - Use the specified INDEX file, if not specified,
  2339.                           the filename 'EXTINDEX.LIB' is assumed.
  2340.     
  2341.                 m=file  - Add named source file as a MIDDLE file.
  2342.     
  2343.                 p=file  - Add named source file as a PREFIX file.
  2344.     
  2345.                 -q      - Quiet mode: SLIB will not display informational
  2346.                           messages or ask for permission to update index.
  2347.     
  2348.                 r=file  - Remove the named file from the index.
  2349.     
  2350.                 s=file  - Add named source file as a SUFFIX file.
  2351.     
  2352.                 -w      - Write inhibit:  SLIB will not write the updated
  2353.                           library index.  This is useful if you just want
  2354.                           to see what would happen if you add or remove a
  2355.                           file.
  2356.     MICRO-C C-FLEA Compiler                                          Page: 50
  2357.  
  2358.  
  2359.        8.9 Making a source library
  2360.     
  2361.              To make a complete source linkable library, follow these  basic
  2362.           steps:
  2363.     
  2364.           1) If you have assembly language library functions, run the SINDEX
  2365.              utility to create an index file with the names of  any  symbols
  2366.              defined in them. Edit this file and remove all names which  are
  2367.              LOCAL to the files. Only the global function and variable names
  2368.              should remain. NOTE: Also leave in any other symbols  or  names
  2369.              which you don't want changed by SCONVERT.
  2370.     
  2371.           2) Use SCONVERT to convert  the  assembly  language  sources  into
  2372.              library format, using the index file created above as your KEEP
  2373.              file (K=EXTINDEX.LIB). You may send the output  files  directly
  2374.              to your source library directory.
  2375.     
  2376.           3) Edit the converted assembly  language  sources  to  change  any
  2377.              declarations for uninitialized data into '$DD' directives,  and
  2378.              to add any '$SE' and '$EX' directives which may be needed.
  2379.     
  2380.           4) Compile all of your 'C' library functions to assembly language,
  2381.              using a code generator which outputs the appropriate directives
  2382.              for SLINK. Send the ASM output files  to  your  source  library
  2383.              directory.
  2384.     
  2385.           5) From within your library  directory,  run  the  SINDEX  utility
  2386.              again. This will create  an  index  file  (EXTINDEX.LIB)  which
  2387.              contains the names of all global symbols.
  2388.     
  2389.           6) Edit the index file and remove any non-public symbol names. You
  2390.              should also change the headers for the '<', '^' and '>'  files,
  2391.              and add the '$' record for reserved memory information.
  2392.     
  2393.           7) Run the SLIB utility, to check the new  library  for  duplicate
  2394.              symbols,  unresolved  external   references   and   any   other
  2395.              inconsistancies.
  2396.     MICRO-C C-FLEA Compiler                                          Page: 51
  2397.  
  2398.  
  2399.     9. THE MAKE UTILITY
  2400.     
  2401.           The MAKE utility provides a method of automating the  building  of
  2402.        larger programs consisting of more that one module. The main  benefit
  2403.        of MAKE is that it keeps track of  the  files  that  each  module  is
  2404.        dependant on, and will rebuild a module if any of  those  files  have
  2405.        been modified since  the  module  was  last  built.  This  frees  the
  2406.        programmer from  the  task  of  remembering  which  files  have  been
  2407.        changed, and the commands needed to rebuild the dependant modules.
  2408.     
  2409.        9.1 MAKEfiles
  2410.     
  2411.              To use MAKE, you must first create a MAKEFILE, which is a  text
  2412.           file containing entries for each module in the program. Each entry
  2413.           consists of a DEPENDANCY list, and a series of COMMANDS.
  2414.     
  2415.           9.1.1 MAKEfile Entries
  2416.     
  2417.                 A dependency list in MAKE is a line which contains the  name
  2418.              of the module, followed by a ':', followed by the names of  any
  2419.              files on which it depends. The module name MUST begin in column
  2420.              1.
  2421.     
  2422.                 When MAKE is invoked, it will process each dependancy  list,
  2423.              and  will  execute  any  following  commands  (up  to   another
  2424.              dependancy list) if (1) the module does not exist,  or  (2)  if
  2425.              any of the files to the right of the ':' have a timestamp which
  2426.              is later than that of the module. For example:
  2427.     
  2428.                 main.asm : main.c main.h \\mc\\stdio.h
  2429.                     \\mc\\mccCF main.c main.tmp
  2430.                     \\mc\\mcoCF main.tmp main.asm
  2431.                     -del main.tmp
  2432.     
  2433.                 In the above example, the 'main.asm' would  be  rebuilt  (by
  2434.              compiling and optimizing 'main.c') if either it did not already
  2435.              exist, or any of 'main.c', 'main.h' or '\mc\stdio.h' was  found
  2436.              to have a later timestamp.
  2437.     
  2438.                 The '-' preceeding the 'del' command prevents it from  being
  2439.              displayed. Unless the '-q' option is enabled, MAKE will display
  2440.              any commands not preceeded by '-' as they are executed.
  2441.     
  2442.                 NOTE: To enter a single '\' in the MAKEFILE,  you  must  use
  2443.              '\\', this is because like 'C',  MAKE  uses  '\'  to  "protect"
  2444.              special  characters  which  otherwise  are  used  for   special
  2445.              functions (such as '\', '$' and '#'). The first '\'  "protects"
  2446.              the second one, allowing it to pass through as source text.
  2447.     MICRO-C C-FLEA Compiler                                          Page: 52
  2448.  
  2449.  
  2450.           9.1.2 Macro Substitutions
  2451.     
  2452.                 Sometimes in a MAKEFILE, you have a single file or directory
  2453.              path that you use  over  and  over  again.  If  it  is  a  long
  2454.              directory path, this may  involve  a  lot  of  typing,  and  it
  2455.              becomes inconvenient to change that name (if you want to use  a
  2456.              different directory etc.) because it is repeated many times.
  2457.     
  2458.                 MAKE includes a MACRO facility, which allows you  to  define
  2459.              variable names which will be replaced with a text  string  when
  2460.              used in subsequent MAKEfile lines. Names are defined by placing
  2461.              them in the MAKEfile, followed by '=',  and  the  text  string.
  2462.              Macro names being defined MUST begin in  column  one,  and  may
  2463.              consist of the characters ('a'-'z', 'A'-'Z', '0'-'9', and '_').
  2464.     
  2465.                 Whenever MAKE encounters a '$' in the  file,  it  takes  the
  2466.              name immediately following, and performs the macro replacement:
  2467.     
  2468.                 mcdir = \\mc
  2469.                 main.asm : main.c main.h $mcdir\\stdio.h
  2470.                     $mcdir\\mccCF main.c main.tmp
  2471.                     $mcdir\\mcoCF main.tmp main.asm
  2472.                     del main.tmp
  2473.     
  2474.     
  2475.                 When a macro name is immediately  followed  by  alphanumeric
  2476.              text, use a single '\' to  separate  it  from  the  text.  This
  2477.              "protects"  the  first  character  of  the  text   from   being
  2478.              interpreted as part of the macro name:
  2479.     
  2480.                 mcdir = \\mc\\
  2481.                 main.asm : main.c main.h $mcdir\stdio.h
  2482.                     $mcdir\mccCF main.c main.tmp
  2483.                     $mcdir\mcoCF main.tmp main.asm
  2484.                     del main.tmp
  2485.     
  2486.                 There  are  several  predefined  macro  symbols  which   are
  2487.              available:
  2488.     
  2489.     
  2490.                 $*      = The full name of the dependant module (name.type).
  2491.                 $@      = The name only of the dependant module.
  2492.                 $.      = The full name of each file in the dependancy list,
  2493.                           separated from each other by a single space.
  2494.                 $,      = The full name of each file in the dependancy list,
  2495.                           separated from each other by a single comma.
  2496.                 $:      = The name only of each file in the dependancy list,
  2497.                           separated from each other by a single space.
  2498.                 $;      = The name only of each file in the dependancy list,
  2499.                           separated from each other by a single comma.
  2500.     MICRO-C C-FLEA Compiler                                          Page: 53
  2501.  
  2502.  
  2503.                 File names in the dependancy list which are preceeded by '-'
  2504.              will not be included in the '$. $, $: $;' macro expansions:
  2505.     
  2506.                 mcdir = \\mc
  2507.                 main.asm : main.c -main.h -$mcdir\\stdio.h
  2508.                     $mcdir\\mccCF $. $@.TMP
  2509.                     $mcdir\\mcoCF $@.TMP $*
  2510.                     del $@.TMP
  2511.     
  2512.           9.1.3 MAKEfile Comments
  2513.     
  2514.                 Whenever MAKE encounters the '#' character in the  MAKEFILE,
  2515.              it treats the remainder of the line as a comment, and does  not
  2516.              process it:
  2517.     
  2518.                 # Define Directories
  2519.                 mcdir = \\mc
  2520.     
  2521.                 # Build the MAIN module
  2522.                 main.asm : main.c -main.h -$mcdir\\stdio.h  # Dependants
  2523.                     $mcdir\\mccCF $. $@.TMP                 # Compile
  2524.                     $mcdir\\mcoCF $@.TMP $*                 # Optimize
  2525.                     del $@.TMP                              # Delete tmp
  2526.     
  2527.           9.1.4 Ordering the MAKEfile
  2528.     
  2529.                 MAKE processes the MAKEfile is sequential fashion, with  the
  2530.              entries near the top being processed before  the  entries  near
  2531.              the bottom. To insure that each module is built  properly,  any
  2532.              files appearing in the dependancy list for a module  which  are
  2533.              themselves dependant  on  other  files,  should  have  MAKEfile
  2534.              entries which occur BEFORE the entries for  the  modules  which
  2535.              are dependant on them:
  2536.     
  2537.                 # Define Directories
  2538.                 mcdir = \\mc
  2539.                 # Build the MAIN module
  2540.                 main.asm : main.c -main.h -$mcdir\\stdio.h
  2541.                     $mcdir\\mccCF $. $@.TMP
  2542.                     $mcdir\\mcoCF $@.TMP $*
  2543.                     del $@.TMP
  2544.                 # Build the SUB module
  2545.                 sub.asm : sub.c -sub.h
  2546.                     $mcdir\\mccCF $. $@.TMP
  2547.                     $mcdir\\mcoCF $@.TMP $*
  2548.                     del $@.TMP
  2549.                 # Link the final file & generate listing
  2550.                 # NOTE: If either of the above modules is rebuilt,
  2551.                 #       this entry will be guarenteed to execute.
  2552.                 prog.hex : main.asm sub.asm
  2553.                     $mcdir\\slink $. $@.asm l=\mc\libCF
  2554.                     $mcdir\\asmCF $@ -fs
  2555.     MICRO-C C-FLEA Compiler                                          Page: 54
  2556.  
  2557.  
  2558.        9.2 Directives
  2559.     
  2560.              Like 'C', MAKE recognizes several "directives" in the MAKEfile.
  2561.           These  directives  are  only  recognized  if  they  occur  at  the
  2562.           beginning of the input line:
  2563.     
  2564.           9.2.1 @include <filename>
  2565.     
  2566.                 This command causes the indicated file to be opened and read
  2567.              in as the source  text.  When  the  end  of  the  new  file  is
  2568.              encountered, processing will continue with the  line  following
  2569.              "@include" in the original MAKEfile.
  2570.     
  2571.           9.2.2 @ifdef <name> [name...]
  2572.     
  2573.                 Processes the following lines (up to @else of  @endif)  only
  2574.              if one of the given MACRO names is defined. NOTE: <name> should
  2575.              not be preceeded by '$', otherwise its CONTENTS will be tested.
  2576.     
  2577.           9.2.3 @ifndef <name> [name...]
  2578.     
  2579.                 Processes the following lines (up to @else of  @endif)  only
  2580.              if one of the given MACRO name is NOT defined.
  2581.     
  2582.           9.2.4 @ifeq <word1> <word2> [word3...]
  2583.     
  2584.                 Processes the following lines (up to @else of  @endif)  only
  2585.              if the first word matches one of the remaining  words  exactly.
  2586.              This is useful for testing the value of a defined MACRO symbol.
  2587.     
  2588.           9.2.5 @ifne <word1> <word2>
  2589.     
  2590.                 Processes the following lines (up to @else or  @endif)  only
  2591.              if the first word does not match any of the following words.
  2592.     
  2593.           9.2.6 @else
  2594.     
  2595.                 Processes the following lines (up to  @endif)  only  if  the
  2596.              preceeding @ifdef, @ifndef, @ifeq or @ifne was false.
  2597.     
  2598.           9.2.7 @endif
  2599.     
  2600.                 Terminates @ifdef, @ifndef, @ifeq and @ifne.
  2601.     
  2602.           9.2.8 @type <text>
  2603.     
  2604.                 Displays the following text.
  2605.     
  2606.           9.2.9 @abort [text]
  2607.     
  2608.                 Terminates MAKE with an 'Aborted!' message. Any text on  the
  2609.              remainder of the line will be appended to the message.
  2610.     MICRO-C C-FLEA Compiler                                          Page: 55
  2611.  
  2612.  
  2613.        9.3 The MAKE command
  2614.     
  2615.              The format of the MAKE command line is:
  2616.     
  2617.                            MAKE [makefile] [options]
  2618.     
  2619.              [makefile] is the name of the MAKEfile to process. If  no  name
  2620.           is given, MAKE assumes the default name 'MAKEFILE'.
  2621.     
  2622.           9.3.1 Command Line Options
  2623.     
  2624.                 MAKE accepts the following command line [options]:
  2625.     
  2626.                 ?       - Causes MAKE to output a short summary  of  the
  2627.                           available command line options.
  2628.     
  2629.                 -d      - Instructs MAKE to operate in "debug" mode, and
  2630.                           display the commands which it  would  execute,
  2631.                           without actually executing them. This provides
  2632.                           a method of quickly testing the MAKEFILE.
  2633.     
  2634.                 -q      - Instructs MAKE to be quiet, and not display the
  2635.                           informational messages and commands executed as
  2636.                           it progresses.
  2637.     
  2638.         <name>=<text>   - Pre-defines a macro  of  the  specified  <name>
  2639.                           with the string value  <text>.  This  OVERRIDES
  2640.                           any definition within the MAKEfile,  which  may
  2641.                           be used to establish a "default" value.
  2642.     MICRO-C C-FLEA Compiler                                          Page: 56
  2643.  
  2644.  
  2645.        9.4 The TOUCH command
  2646.     
  2647.              TOUCH is a small utility program which sets  the  timestamp  of
  2648.           one or more files to the current or  specified  time/date.  It  is
  2649.           useful as a  method  of  forcing  MAKE  to  recognize  a  file  as
  2650.           "changed", even when it has not.
  2651.     
  2652.              For example, if  you  had  decided  to  "undo"  several  recent
  2653.           changes by restoring a backup of 'main.c', the restored file  will
  2654.           probably have a timestamp which is  older  than  the  last  module
  2655.           which was built. In this case, MAKE would be unaware that the file
  2656.           has changed, and would therefore not rebuild the module.
  2657.     
  2658.              The TOUCH command could then be used to "update" the  timestamp
  2659.           of 'main.c' to the current time, causing MAKE to recognize it as a
  2660.           changed file.
  2661.     
  2662.                                   TOUCH main.c
  2663.     
  2664.              You could also use TOUCH to force rebuilding of several files:
  2665.     
  2666.                            TOUCH main.c sub1.c sub2.c
  2667.     
  2668.              Or even ALL '.C' files:
  2669.     
  2670.                                    TOUCH *.c
  2671.     
  2672.              TOUCH can also be used to set the timestamp of  a  file  to  an
  2673.           arbritrary value, this may be useful  to  PREVENT  a  change  from
  2674.           causing an update:
  2675.     
  2676.                          TOUCH main.c t=0:00 d=31/10/80
  2677.     
  2678.              NOTE: Use of the 't=' or 'd=' parameters to  TOUCH  allows  the
  2679.           possibility that a changed file  will  go  unnoticed.  CAUTION  is
  2680.           advised.
  2681.     
  2682.              The MSDOS  implementation  of  TOUCH  supports  '-h'  and  '-s'
  2683.           options, which cause it to set  the  timestamp  of  HIDDEN  and/or
  2684.           SYSTEM files. If these options are not used, TOUCH will not affect
  2685.           those types of files.
  2686.     MICRO-C C-FLEA Compiler                                          Page: 57
  2687.  
  2688.  
  2689.     10. EDT - Text editor
  2690.     
  2691.        10.1 Introduction
  2692.     
  2693.              EDT is a fully  featured,  in-memory,  text  editor,  which  is
  2694.           suitable for entry and editing of MICRO-C and ASM source programs.
  2695.           It operates in either a line-by-line, or a visual screen format.
  2696.     
  2697.              In line-by-line mode, EDT performs no direct  screen  accesses,
  2698.           and may be operated over a serial port using CTTY.
  2699.     
  2700.              EDT is invoked with the command 'EDT <filename>'. If the  named
  2701.           file already exists, EDT will load and edit it, otherwise a  blank
  2702.           file is presented. If the optional '-v'  qualifier  is  specified,
  2703.           EDT will start-up in line-by-line mode, otherwise it starts up  in
  2704.           visual mode.
  2705.     
  2706.                 eg:     edt thefile.dat         <- Visual mode
  2707.                         edt myfile.dat -v       <- Line by Line
  2708.     
  2709.        10.2 Line mode operation
  2710.     
  2711.           10.2.1 Line ranges
  2712.     
  2713.                 Most commands accept a "line-range"  which  is  an  optional
  2714.              specification controlling the range  of  lines  for  which  the
  2715.              command  has  effect.  Unless  otherwise  stated,  the  default
  2716.              line-range assumed for each command is the "current" line (*).
  2717.     
  2718.                 The "current" line is the line at which EDT is positioned in
  2719.              line by line mode, and is also the line on which the cursor  is
  2720.              positioned in visual mode.
  2721.     
  2722.                 The following are the valid line range formats:
  2723.     
  2724.                    *        - The "current" line
  2725.                    /        - The entire file
  2726.                    =        - The tagged lines
  2727.                    0        - The end of the file
  2728.                    <n>      - Line number <n>, (<n> >= 1)
  2729.                    <r>,<r>  - Range between beginning of two other ranges.
  2730.     
  2731.                 The '+' and '-' characters may be used to add or subtract  a
  2732.              constant value from a line range.
  2733.     
  2734.                     eg: '0-12' <- 12 lines from end of file
  2735.     
  2736.                 If '+' or '-' is used but no range is specified,  an  offset
  2737.              from the current line is assumed.
  2738.     
  2739.                   eg: '+12' <- 12 lines from the current line.
  2740.     
  2741.                 The  line  range  specification   is   entered   immediately
  2742.              preceeding the command name.
  2743.     
  2744.                          ie: '<r><command> <operands>'
  2745.     MICRO-C C-FLEA Compiler                                          Page: 58
  2746.  
  2747.  
  2748.           10.2.2 Line mode commands
  2749.     
  2750.              C - Copy text
  2751.     
  2752.                    The 'C'opy command performs a copy of the active range of
  2753.                 lines, placeing the copy directly ahead of the current line.
  2754.     
  2755.                 Examples:
  2756.     
  2757.                     C               - Duplicate current line
  2758.                     1,10C           - Copy lines 1 to 10 inclusive
  2759.                     =C              - Copy tagged lines
  2760.                     /C              - Duplicate entire file (must be at end)
  2761.     
  2762.              D - Delete text
  2763.     
  2764.                    The 'D'elete command deletes the active range of lines.
  2765.     
  2766.                 Examples:
  2767.     
  2768.                     D               - Delete current line
  2769.                     -5,+5D          - Delete 11 lines -5 to +5 from current
  2770.                     /D              - Delete entire file
  2771.     
  2772.              F - File information
  2773.     
  2774.                    This command displays information about  the  file  being
  2775.                 edited, includes the filename, the size of the file in lines
  2776.                 and characters, and the size and position of  the  specified
  2777.                 line range.
  2778.     
  2779.                 Examples:
  2780.     
  2781.                     F               - Display file & current line information
  2782.                     =F              - Display file & tagged lines information
  2783.     
  2784.              I - Insert new text
  2785.     
  2786.                    The 'I'nsert command prompts for  'Input:',  and  inserts
  2787.                 all lines typed directly ahead of the active range. Enter  a
  2788.                 null line to exit.
  2789.     
  2790.                 Examples:
  2791.     
  2792.                     I               - Insert ahead of current line
  2793.                     /I              - Insert at start of file
  2794.                     0I              - Insert at end of file
  2795.     MICRO-C C-FLEA Compiler                                          Page: 59
  2796.  
  2797.  
  2798.              L - List text in simple form
  2799.     
  2800.                    The 'L'ist command displays the active  range  of  lines.
  2801.                 The  display  does  not  include  line  numbers  or  special
  2802.                 indications.  'L'ist  is  faster  and  mode  efficent   that
  2803.                 'P'rint.
  2804.     
  2805.                 Examples:
  2806.     
  2807.                     L               - List current line
  2808.                     /L              - List entire file
  2809.                     -10,+10L        - List 21 lines, centered on current
  2810.     
  2811.              M - Move text
  2812.     
  2813.                    The 'M'ove command moves the active range of lines to the
  2814.                 location directly ahead of the current line.
  2815.     
  2816.                 Examples:
  2817.     
  2818.                     =M              - Move tagged lines
  2819.                     +1M             - Interchange active & next line
  2820.     
  2821.              P - Print text (Enhanced 'L'ist)
  2822.     
  2823.                    The 'P'rint command displays the active range  of  lines.
  2824.                 This display includes the line number which may be  preceded
  2825.                 by a special indication flag ('*' for current line, '='  for
  2826.                 tagged lines).
  2827.     
  2828.                 Examples:
  2829.     
  2830.                     P               - Display current line
  2831.                     /P              - Display entire file
  2832.     
  2833.              Q - Quit (exit) editor
  2834.     
  2835.                    The 'Q'uit command exits the editor.  This  command  will
  2836.                 not allow an exit if unsaved  changes  are  present  in  the
  2837.                 file.
  2838.     
  2839.                 Examples:
  2840.     
  2841.                     Q               - Quit editor
  2842.     
  2843.              QQ - Unconditional 'Q'uit
  2844.     
  2845.                    The 'QQ'uit command exits the editor unconditionaly.
  2846.     
  2847.                 Examples:
  2848.     
  2849.                     QQ              - Quit unconditionaly.
  2850.     MICRO-C C-FLEA Compiler                                          Page: 60
  2851.  
  2852.  
  2853.              R <filename> - Read file
  2854.     
  2855.                    The 'R'ead command  reads  the  entire  contents  of  the
  2856.                 specified file, and inserts it directly ahead of the  active
  2857.                 range.
  2858.     
  2859.                 Examples:
  2860.     
  2861.                     Rabc            - Insert file 'abc' at current
  2862.                     /Rabc           - Insert file 'abc' at start
  2863.                     0Rabc           - Append file 'abc' at end
  2864.     
  2865.              S<dc><search><dc><replace> - Substitute
  2866.     
  2867.                    The 'S'ubstitute command searches  the  active  range  of
  2868.                 lines, and replaces all occurrances of the  string  <search>
  2869.                 with the string <replace>. The <dc> delimiter character  may
  2870.                 be any character not contained within the <search> string.
  2871.     
  2872.                 Examples:
  2873.     
  2874.                     S'abc'def       - Change 'abc' to 'def' in current
  2875.                     /S'abc'def      - Change 'abc' to 'def' in entire file
  2876.                     =S'abc'def      - Change 'abc' to 'def' in tagged lines
  2877.     
  2878.              T - Tag lines
  2879.     
  2880.                    The  'T'ag  command  tags  the  active  range  of  lines,
  2881.                 allowing them to be referred  to  by  '='  in  a  subsequent
  2882.                 command range.
  2883.     
  2884.                 Examples:
  2885.     
  2886.                     T               - Tag current line
  2887.                     1,10T           - Tag lines 1 to 10
  2888.                     *,+5T           - Tag six lines starting at current
  2889.     
  2890.              V - Switch Visual Mode
  2891.     
  2892.                    The 'V' command causes EDT to switch visual  modes.  This
  2893.                 enters visual mode if EDT was previously  in  line  by  line
  2894.                 mode, and enters line by line mode if previously  in  visual
  2895.                 mode.
  2896.     
  2897.                 Examples:
  2898.     
  2899.                     V               - Switch visual modes
  2900.     MICRO-C C-FLEA Compiler                                          Page: 61
  2901.  
  2902.  
  2903.              W [filename] - Write to file
  2904.     
  2905.                    The 'W' command writes the active range of lines  to  the
  2906.                 named file, or to the original file edited  if  no  name  is
  2907.                 specified. Use of this command also resets the FILE  CHANGED
  2908.                 flag, allowing exit via 'q'.
  2909.     
  2910.                    The default line range assumed for 'W'rite is the  entire
  2911.                 file.
  2912.     
  2913.                 Examples:
  2914.     
  2915.                     W               - Write entire file
  2916.                     *W              - Write current line
  2917.                     Wabc            - Write entire file to 'abc'
  2918.                     =Wabc           - Write tagged lines to 'abc'
  2919.     
  2920.              X [filename] - Write file and eXit
  2921.     
  2922.                    This command behaves  exactly  as  the  'W'rite  command,
  2923.                 followed immediatly by  a  'Q'uit  command.  It  provides  a
  2924.                 shorthand way of saving your file and leaving the editor.
  2925.     
  2926.                 Examples:
  2927.     
  2928.                     X               - Write file & exit
  2929.                     Xabc            - Write to 'abc' and exit
  2930.     
  2931.              ?<text> - Search for text
  2932.     
  2933.                    The '?' command  moves  the  active  line  to  the  first
  2934.                 occurance of the specified string within the active range.
  2935.     
  2936.                    The default range assumed for '?' is one  character  past
  2937.                 the current cursor position (in visual mode)  or  the  first
  2938.                 character of the active line (In line by line mode), through
  2939.                 to the end of the file.
  2940.     
  2941.                 Examples:
  2942.     
  2943.                     ?string         - Find next occurance of "string"
  2944.                     /?string        - Find first occurance of "string"
  2945.     
  2946.              $<command> - Execute DOS command
  2947.     
  2948.                    The '$' command executes the specified DOS command.
  2949.     
  2950.                 Examples:
  2951.     
  2952.                     $dir            - Execute 'dir' command
  2953.     MICRO-C C-FLEA Compiler                                          Page: 62
  2954.  
  2955.  
  2956.              <no command> - Goto line
  2957.     
  2958.                    If a line range is given  without  a  command,  EDT  will
  2959.                 reposition the "current"  line  to  the  beginning  of  that
  2960.                 range.
  2961.     
  2962.                 Examples:
  2963.     
  2964.                     100             - Move to line 100
  2965.                     /               - Move to start of file
  2966.                     0               - Move to end of file
  2967.                     =               - Move to tagged line(s)
  2968.     
  2969.        10.3 Visual mode operation
  2970.     
  2971.              When in VISUAL mode, EDT presents  a  window  on  the  terminal
  2972.           screen which displays the contents  of  a  section  of  the  file.
  2973.           Editing of the file may be performed directly on  the  screen  via
  2974.           special function keys, and the screen is updated so that  you  see
  2975.           your changes as they are being performed.
  2976.     
  2977.              Any  control  characters  which  exist  in  the  file  will  be
  2978.           displayed as the  corresponding  printable  character  in  reverse
  2979.           video.
  2980.     
  2981.              If the end of the file is within the area shown on the  screen,
  2982.           the message '*EOF*' is displayed in reverse video.
  2983.     
  2984.           10.3.1 Entering text
  2985.     
  2986.                 Text may be entered into the file being  edited,  simply  by
  2987.              typeing it at the terminal keyboard. EDT  automatically  places
  2988.              the text in the file, and updates the screen to reflect the new
  2989.              contents. The position of the  terminal  cursor  indicates  the
  2990.              position at which the text will be entered.
  2991.     
  2992.           10.3.2 Positioning the cursor
  2993.     
  2994.                 The arrow keys on the terminal  may  be  used  to  move  the
  2995.              cursor around the displayed image. Moving beyond the bottom  of
  2996.              the screen causes EDT to scroll forward one line, and shift the
  2997.              screen up. Moving beyond the top of the screen  causes  EDT  to
  2998.              scroll backward one half screen, and redisplay the text.
  2999.     
  3000.                 EDT will perform sideways scrolling of the display to  allow
  3001.              the cursor to access the entire width of lines which are larger
  3002.              than 80 columns.
  3003.     MICRO-C C-FLEA Compiler                                          Page: 63
  3004.  
  3005.  
  3006.           10.3.3 Visual mode function keys
  3007.     
  3008.                 The following keys on  the  IBM  PC  keyboard  have  special
  3009.              meaning to EDT:
  3010.     
  3011.              Right arrow
  3012.     
  3013.                    Moves the cursor forward one  character  positon  in  the
  3014.                 file, if at the end of a line, the cursor  will  advance  to
  3015.                 the first position of the next line.
  3016.     
  3017.              Left arrow
  3018.     
  3019.                    Moves the cursor backward one character  positon  in  the
  3020.                 file, if at the beginning of a line, the cursor will  backup
  3021.                 to the last position of the previous line.
  3022.     
  3023.              Up arrow
  3024.     
  3025.                    Moves the cursor up one  line.  If  at  the  top  of  the
  3026.                 screen, the display will scroll  backwards  by  one  half  a
  3027.                 screen page.
  3028.     
  3029.              Down arrow
  3030.     
  3031.                    Moves the cursor down one line. If at the bottom  of  the
  3032.                 screen, the display will scroll forward by one line.
  3033.     
  3034.                    The cursor may appear to jump back and  forth  as  it  is
  3035.                 moved up and down, if it ancounters lines which are  shorter
  3036.                 than the current character  position  within  the  line,  or
  3037.                 lines which contain tabs. This is because whenever possible,
  3038.                 the cursor is  returned  to  the  same  number  of  physical
  3039.                 characters from the start of the line as is was on the first
  3040.                 line from which the UP or DOWN arrow was pressed.
  3041.     
  3042.              Page up
  3043.     
  3044.                    This key pages backward one  screen.  (Top  line  becomes
  3045.                 bottom)
  3046.     
  3047.              Page down
  3048.     
  3049.                    This key pages forward one screen. (Bottom  line  becomes
  3050.                 top)
  3051.     
  3052.              Home
  3053.     
  3054.                    Moves the cursor to the beginning of the line. If  it  is
  3055.                 already at the beginning of a  line,  it  is  moved  to  the
  3056.                 beginning of the previous line.
  3057.     
  3058.              End
  3059.     
  3060.                    Moves the cursor to the end of the line.  If  already  at
  3061.                 the end of a line, it is moved to the end of the next line.
  3062.     MICRO-C C-FLEA Compiler                                          Page: 64
  3063.  
  3064.  
  3065.              CTRL-PgUp
  3066.     
  3067.                    This key moves the cursor to the beginning of  the  first
  3068.                 line in the file.
  3069.     
  3070.              CTRL-PgDn
  3071.     
  3072.                    This key moves the cursor to the end of the file.
  3073.     
  3074.              CTRL-Right Arrow
  3075.     
  3076.                    Moves the cursor to the beginning of the next word.
  3077.     
  3078.              CTRL-Left Arrow
  3079.     
  3080.                    Moves the cursor to the beginning of the previous word.
  3081.     
  3082.              Ins
  3083.     
  3084.                    Toggles between character INSERT and OVERWRITE  mode.  In
  3085.                 INSERT mode,  all  characters  typed  at  the  terminal  are
  3086.                 inserted into the text. In OVERWRITE mode, only the  NEWLINE
  3087.                 character and data entered at the end of a line is inserted,
  3088.                 all other characters will overwrite the existing text.
  3089.     
  3090.              Delete
  3091.     
  3092.                    Deletes the character under the  cursor,  without  moving
  3093.                 the cursor.
  3094.     
  3095.              Backspace
  3096.     
  3097.                    Moves the cursor backward to the previous character, then
  3098.                 deletes that character.
  3099.     
  3100.              CTRL-Home
  3101.     
  3102.                    Redraws the screen image of the file.  This  is  normally
  3103.                 used in the case of  the  screen  being  corrupted  by  data
  3104.                 transmission  errors,  or  asynchronus  messages  from   the
  3105.                 operating system or its users.
  3106.     
  3107.              F1
  3108.     
  3109.                    Toggles ON/OFF the display of NEWLINE characters  at  the
  3110.                 end of each line of text.
  3111.     
  3112.              F2
  3113.     
  3114.                    Displays  the  current  cursor  position,  including  the
  3115.                 actual and character offsets from the start of line.
  3116.     
  3117.              F3
  3118.     
  3119.                    Brings the line the cursor  is  on  to  the  top  of  the
  3120.                 screen.
  3121.     MICRO-C C-FLEA Compiler                                          Page: 65
  3122.  
  3123.  
  3124.              F4
  3125.     
  3126.                    Tags one or more lines for a later operation. The  tagged
  3127.                 lines  are  displayed  in  special  video  if  the  terminal
  3128.                 supports it. Once one line is tagged, pressing this  key  on
  3129.                 another line causes all lines between  them  to  be  tagged.
  3130.                 Pressing it again on the first  line  of  the  tagged  range
  3131.                 removes the tags.
  3132.     
  3133.              F5
  3134.     
  3135.                    Deletes from the cursor position to the end of  the  line
  3136.                 (inclusive).
  3137.     
  3138.              F6
  3139.     
  3140.                    Deletes from the cursor position to the end of  the  line
  3141.                 (exclusive).
  3142.     
  3143.              F7
  3144.     
  3145.                    Inserts the deleted line text (From  Function  key  8  or
  3146.                 Function key 9) at the current cursor position.
  3147.     
  3148.              F10 or Keypad '+'
  3149.     
  3150.                    Prompts for a line mode command, and executes it. See the
  3151.                 section on line mode operation.
  3152.     
  3153.              F9 or Keypad '-'
  3154.     
  3155.                    Re-executes the last line mode command entered.
  3156.     MICRO-C C-FLEA Compiler                                          Page: 66
  3157.  
  3158.  
  3159.     
  3160.                       +----------------------------------+
  3161.                       |                                  |
  3162.                       |  ******************************  |
  3163.                       |  * The MICRO-C/C-FLEA library *  |
  3164.                       |  ******************************  |
  3165.                       |                                  |
  3166.                       +----------------------------------+
  3167.     
  3168.     
  3169.     
  3170.     
  3171.     
  3172.     
  3173.     
  3174.     
  3175.     
  3176.     
  3177.     11. The MICRO-C/C-FLEA Library
  3178.     
  3179.           The  library  functions  described  on  the  following  pages  are
  3180.        currently available in the MICRO-C library as "standard" functions.
  3181.     ABORT                                                             ABORT
  3182.     
  3183.     
  3184.     
  3185.     PROTOTYPE:
  3186.     
  3187.         abort(char *message)
  3188.     
  3189.     
  3190.     ARGUMENTS:
  3191.     
  3192.         message - Pointer to message to display
  3193.     
  3194.     
  3195.     RETURN VALUE:
  3196.     
  3197.         N/A - Function never returns
  3198.     
  3199.     
  3200.     DESCRIPTION:
  3201.     
  3202.           This function writes the string passed as an argument to  standard
  3203.        error, and then terminates the program. This provides a simple method
  3204.        of terminating a  program  on  an  error  condition  with  a  message
  3205.        explaining why.
  3206.     
  3207.     
  3208.     EXAMPLES:
  3209.     
  3210.         abort("Invalid operand\n");
  3211.     ABS                                                                 ABS
  3212.     
  3213.     
  3214.     
  3215.     PROTOTYPE:
  3216.     
  3217.         int abs(int number)
  3218.     
  3219.     
  3220.     ARGUMENTS:
  3221.     
  3222.         number  - Any integer value
  3223.     
  3224.     
  3225.     RETURN VALUE:
  3226.     
  3227.         The absolute value of "number"
  3228.     
  3229.     
  3230.     DESCRIPTION:
  3231.     
  3232.           The "abs" function returns the absolute value of the argument.  If
  3233.        "number" is a positive value, it is returned unchanged. If  negative,
  3234.        the negate of that value is returned (giving a positive result).
  3235.     
  3236.     
  3237.     EXAMPLES:
  3238.     
  3239.         difference = abs(value1 - value2);
  3240.     ATOI                                                               ATOI
  3241.     
  3242.     
  3243.     
  3244.     PROTOTYPE:
  3245.     
  3246.         int atoi(char *string)
  3247.     
  3248.     
  3249.     ARGUMENTS:
  3250.     
  3251.         string  - Pointer to a string containing a decimal number
  3252.     
  3253.     
  3254.     RETURN VALUE:
  3255.     
  3256.         16 bit integer value
  3257.     
  3258.     
  3259.     DESCRIPTION:
  3260.     
  3261.           The "atoi" function converts an ASCII string containing  a  signed
  3262.        decimal number (-32768 to 32767) to a 16 bit value which is returned.
  3263.        An unsigned number of the range (0 to 65535) may also  be  used,  and
  3264.        the result if assigned to an "unsigned" variable will be correct.
  3265.     
  3266.     
  3267.     EXAMPLES:
  3268.     
  3269.         value = atoi("1234");
  3270.         value = atoi("-1");
  3271.     CHKCH                                                             CHKCH
  3272.     
  3273.     
  3274.     
  3275.     PROTOTYPE:
  3276.     
  3277.         int chkch()
  3278.     
  3279.     
  3280.     ARGUMENTS:
  3281.     
  3282.         None
  3283.     
  3284.     
  3285.     RETURN VALUE:
  3286.     
  3287.         0       - No character available from serial port.
  3288.         !0      - Character read from serial port.
  3289.     
  3290.     
  3291.     DESCRIPTION:
  3292.     
  3293.           The "chkch" function checks to see if a character is ready  to  be
  3294.        received from the console serial port. If no character is  available,
  3295.        a zero (0) is returned, otherwise the character is read and its value
  3296.        is  passed  back.  The  CARRIAGE  RETURN  character  (0x0D)  will  be
  3297.        translated into a NEWLINE (0x0A) for compatibility with 'C'.
  3298.     
  3299.     
  3300.     EXAMPLES:
  3301.     
  3302.         if(chkch() == 0x1B)     /* Escape KEY pressed ? */
  3303.             return;
  3304.     CHKCHR                                                           CHKCHR
  3305.     
  3306.     
  3307.     
  3308.     PROTOTYPE:
  3309.     
  3310.         int chkchr()
  3311.     
  3312.     
  3313.     ARGUMENTS:
  3314.     
  3315.         None
  3316.     
  3317.     
  3318.     RETURN VALUE:
  3319.     
  3320.         0-255   - Character read from serial port.
  3321.         -1      - No character was available.
  3322.     
  3323.     
  3324.     DESCRIPTION:
  3325.     
  3326.           The "chkch" function checks to see if a character is ready  to  be
  3327.        received from the console serial port. If no character is  available,
  3328.        a -1 is returned, otherwise the character is read and its "raw" value
  3329.        is passed back (without translation).
  3330.     
  3331.     
  3332.     EXAMPLES:
  3333.     
  3334.         if(chkchr() == '\r')        /* Return KEY pressed ? */
  3335.             return;
  3336.     CONCAT                                                           CONCAT
  3337.     
  3338.     
  3339.     
  3340.     PROTOTYPE:
  3341.     
  3342.         register concat(char *dest, char *source, ...)
  3343.     
  3344.     
  3345.     ARGUMENTS:
  3346.     
  3347.         dest    - Pointer to destination string
  3348.         source  - Pointer to source string
  3349.         ...     - Additional sources may be given
  3350.     
  3351.     
  3352.     RETURN VALUE:
  3353.     
  3354.         None
  3355.     
  3356.     
  3357.     DESCRIPTION:
  3358.     
  3359.           The "concat" function concatinates the given source  strings  into
  3360.        one destination string. The destination string must be  large  enough
  3361.        to hold all of the source strings plus the string  terminator  (zero)
  3362.        byte. No value is returned.
  3363.     
  3364.           NOTE: This function uses a variable number of arguments, and  must
  3365.        be declared as "register" (See "stdio.h").
  3366.     
  3367.     
  3368.     EXAMPLES:
  3369.     
  3370.         concat(filename,"/tmp/", input_name);
  3371.     EXIT                                                               EXIT
  3372.     
  3373.     
  3374.     
  3375.     PROTOTYPE:
  3376.     
  3377.         exit()
  3378.     
  3379.     
  3380.     ARGUMENTS:
  3381.     
  3382.         None
  3383.     
  3384.     
  3385.     RETURN VALUE:
  3386.     
  3387.         N/A - Function never returns
  3388.     
  3389.     
  3390.     DESCRIPTION:
  3391.     
  3392.           This function terminates the execution of the program, and returns
  3393.        control to the on-board monitor.
  3394.     
  3395.     
  3396.     EXAMPLES:
  3397.     
  3398.         exit();     /* Return to monitor */
  3399.     FREE                                                               FREE
  3400.     
  3401.     
  3402.     
  3403.     PROTOTYPE:
  3404.     
  3405.         free(char *ptr)
  3406.     
  3407.     
  3408.     ARGUMENTS:
  3409.     
  3410.         ptr     - Pointer to a previously allocated memory block
  3411.     
  3412.     
  3413.     RETURN VALUE:
  3414.     
  3415.         None
  3416.     
  3417.     
  3418.     DESCRIPTION:
  3419.     
  3420.           The "free" function releases (de-allocates) a block of memory that
  3421.        was obtained via a call to "malloc", and returns it to the heap. This
  3422.        makes it available for use by other memory allocations.
  3423.     
  3424.     
  3425.     EXAMPLES:
  3426.     
  3427.         if(!(ptr = malloc(BUFSIZ)))     /* Allocate a temporary buffer */
  3428.             abort("Not enough memory");
  3429.         /* ... Use the memory block ... */
  3430.         free(ptr);                      /* Release temporary buffer */
  3431.     GETCH                                                             GETCH
  3432.     
  3433.     
  3434.     
  3435.     PROTOTYPE:
  3436.     
  3437.         int getch()
  3438.     
  3439.     
  3440.     ARGUMENTS:
  3441.     
  3442.         None
  3443.     
  3444.     
  3445.     RETURN VALUE:
  3446.     
  3447.         Value of a character read from the serial port.
  3448.     
  3449.     
  3450.     DESCRIPTION:
  3451.     
  3452.           This function reads a single character  from  the  console  serial
  3453.        port, and returns it as a positive value in the range of 0 to 255. If
  3454.        the character is a carriage  return  (0x0D),  is  translated  into  a
  3455.        NEWLINE (0x0A) for compatibility with 'C'.
  3456.     
  3457.     
  3458.     EXAMPLES:
  3459.     
  3460.         while(getch() != 0x1B);     /* Wait for an ESCAPE character */
  3461.     GETCHR                                                           GETCHR
  3462.     
  3463.     
  3464.     
  3465.     PROTOTYPE:
  3466.     
  3467.         int getchr()
  3468.     
  3469.     
  3470.     ARGUMENTS:
  3471.     
  3472.         None
  3473.     
  3474.     
  3475.     RETURN VALUE:
  3476.     
  3477.         Value of a character read from the serial port.
  3478.     
  3479.     
  3480.     DESCRIPTION:
  3481.     
  3482.           This function reads a single character  from  the  console  serial
  3483.        port, and returns it as a positive value in the range of  0  to  255.
  3484.        The  character  is  read  in  "raw"  format,  with  no   translations
  3485.        performed.
  3486.     
  3487.     
  3488.     EXAMPLES:
  3489.     
  3490.         while(getchr() != '\r');        /* Wait for a RETURN */
  3491.     GETSTR                                                           GETSTR
  3492.     
  3493.     
  3494.     
  3495.     PROTOTYPE:
  3496.     
  3497.         char *getstr(char *buffer, int size)
  3498.     
  3499.     
  3500.     ARGUMENTS:
  3501.     
  3502.         buffer  - Pointer to string to receive line
  3503.         size    - Maximum size of line to read
  3504.     
  3505.     
  3506.     RETURN VALUE:
  3507.     
  3508.         The number of characters received into the line.
  3509.     
  3510.     
  3511.     DESCRIPTION:
  3512.     
  3513.           The "getstr" function reads a string of character from the  serial
  3514.        port and places them into the specified character buffer until either
  3515.        a NEWLINE character is encountered, or the limit of "size"  character
  3516.        is read.
  3517.     
  3518.           The string is terminated with the standard  NULL  (00)  character.
  3519.        The trailing NEWLINE '\n' character is NOT  included  in  the  output
  3520.        buffer.
  3521.     
  3522.           The BACKSPACE or DEL keys can be used to edit the input line.
  3523.     
  3524.     
  3525.     EXAMPLES:
  3526.     
  3527.         getstr(input_line, 80);
  3528.     INPx                                                               INPx
  3529.     
  3530.     
  3531.     
  3532.     PROTOTYPE:
  3533.     
  3534.         int inp1();
  3535.         int inp2();
  3536.         int inp3();
  3537.         int inp4();
  3538.     
  3539.     
  3540.     ARGUMENTS:
  3541.     
  3542.         None
  3543.     
  3544.     
  3545.     RETURN VALUE:
  3546.     
  3547.         8 bit value (0-255) read from the input port.
  3548.     
  3549.     
  3550.     DESCRIPTION:
  3551.     
  3552.           These functions read an 8 bit value from a parallel I/O port.
  3553.     
  3554.     
  3555.     EXAMPLES:
  3556.     
  3557.         if(inp1() & 0x01)
  3558.             outp2(inp2() | 0x01);
  3559.     ISALNUM                                                         ISALNUM
  3560.     
  3561.     
  3562.     
  3563.     PROTOTYPE:
  3564.     
  3565.         int isalnum(char c)
  3566.     
  3567.     
  3568.     ARGUMENTS:
  3569.     
  3570.         c       - Any character value
  3571.     
  3572.     
  3573.     RETURN VALUE:
  3574.     
  3575.         1 if 'c' is alphabetic or numeric
  3576.         0 if 'c' is not alphabetic or numeric
  3577.     
  3578.     
  3579.     DESCRIPTION:
  3580.     
  3581.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  3582.        alphabetic letter in either upper or  lower  case  or  if  'c'  is  a
  3583.        numeric digit, otherwise FALSE (0) is returned.
  3584.     
  3585.     
  3586.     EXAMPLES:
  3587.     
  3588.         while(isalnum(*ptr))        /* Copy over symbol name */
  3589.             *name++ = *ptr++;
  3590.     ISALPHA                                                         ISALPHA
  3591.     
  3592.     
  3593.     
  3594.     PROTOTYPE:
  3595.     
  3596.         int isalpha(char c)
  3597.     
  3598.     
  3599.     ARGUMENTS:
  3600.     
  3601.         c       - Any character value
  3602.     
  3603.     
  3604.     RETURN VALUE:
  3605.     
  3606.         1 if 'c' is alphabetic
  3607.         0 if 'c' is not alphabetic
  3608.     
  3609.     
  3610.     DESCRIPTION:
  3611.     
  3612.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  3613.        alphabetic letter in either upper or lower case, otherwise FALSE  (0)
  3614.        is returned.
  3615.     
  3616.     
  3617.     EXAMPLES:
  3618.     
  3619.         flag = isalpha(input_char);
  3620.     ISASCII                                                         ISASCII
  3621.     
  3622.     
  3623.     
  3624.     PROTOTYPE:
  3625.     
  3626.         int isascii(int c)
  3627.     
  3628.     
  3629.     ARGUMENTS:
  3630.     
  3631.         c       - Any character value
  3632.     
  3633.     
  3634.     RETURN VALUE:
  3635.     
  3636.         1 if 'c' is an ASCII character
  3637.         0 if 'c' is not an ASCII character
  3638.     
  3639.     
  3640.     DESCRIPTION:
  3641.     
  3642.           Returns TRUE (1) if the passed character  'c'  is  a  valid  ASCII
  3643.        character (0x00-0xFF), otherwise FALSE (0) is returned.
  3644.     
  3645.     
  3646.     EXAMPLES:
  3647.     
  3648.         if(!isascii(*ptr))
  3649.             abort("Invalid character data");
  3650.     ISCNTRL                                                         ISCNTRL
  3651.     
  3652.     
  3653.     
  3654.     PROTOTYPE:
  3655.     
  3656.         int iscntrl(char c)
  3657.     
  3658.     
  3659.     ARGUMENTS:
  3660.     
  3661.         c       - Any character value
  3662.     
  3663.     
  3664.     RETURN VALUE:
  3665.     
  3666.         1 if 'c' is a "control" character
  3667.         0 if 'c' is not a "control" character
  3668.     
  3669.     
  3670.     DESCRIPTION:
  3671.     
  3672.           Returns TRUE (1) is the passed character 'c' is an ASCII "control"
  3673.        character (0x00-0x1F or 0x7F), otherwise FALSE (0) is returned.
  3674.     
  3675.     
  3676.     EXAMPLES:
  3677.     
  3678.         putch(iscntrl(c) ? '.' : c);    /* Display controls as '.' */
  3679.     ISDIGIT                                                         ISDIGIT
  3680.     
  3681.     
  3682.     
  3683.     PROTOTYPE:
  3684.     
  3685.         int isdigit(char c)
  3686.     
  3687.     
  3688.     ARGUMENTS:
  3689.     
  3690.         c       - Any character value
  3691.     
  3692.     
  3693.     RETURN VALUE:
  3694.     
  3695.         1 if 'c' is numeric
  3696.         0 if 'c' is not numeric
  3697.     
  3698.     
  3699.     DESCRIPTION:
  3700.     
  3701.           Returns TRUE (1) is the passed character 'c'  is  an  ASCII  digit
  3702.        ('0'-'9'), otherwise FALSE (0) is returned.
  3703.     
  3704.     
  3705.     EXAMPLES:
  3706.     
  3707.         value = 0;
  3708.         while(isdigit(*ptr))
  3709.             value = (value * 10) + (*ptr++ - '0');
  3710.     ISGRAPH                                                         ISGRAPH
  3711.     
  3712.     
  3713.     
  3714.     PROTOTYPE:
  3715.     
  3716.         int isgraph(char c)
  3717.     
  3718.     
  3719.     ARGUMENTS:
  3720.     
  3721.         c       - Any character value
  3722.     
  3723.     
  3724.     RETURN VALUE:
  3725.     
  3726.         1 if 'c' is a non-space printable character
  3727.         0 if 'c' is a space or not printable
  3728.     
  3729.     
  3730.     DESCRIPTION:
  3731.     
  3732.           Returns TRUE (1) if the passed character 'c' is a printable  ASCII
  3733.        character other than  a  space  character,  otherwise  FALSE  (0)  is
  3734.        returned.
  3735.     
  3736.     
  3737.     EXAMPLES:
  3738.     
  3739.         putch(isgraph(c) ? c : '.');
  3740.     ISLOWER                                                         ISLOWER
  3741.     
  3742.     
  3743.     
  3744.     PROTOTYPE:
  3745.     
  3746.         int islower(char c)
  3747.     
  3748.     
  3749.     ARGUMENTS:
  3750.     
  3751.         c       - Any character value
  3752.     
  3753.     
  3754.     RETURN VALUE:
  3755.     
  3756.         1 if 'c' is lower case alphabetic
  3757.         0 if 'c' is not lower case alphabetic
  3758.     
  3759.     
  3760.     DESCRIPTION:
  3761.     
  3762.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  3763.        alphabetic letter of lower case, otherwise FALSE (0) is returned.
  3764.     
  3765.     
  3766.     EXAMPLES:
  3767.     
  3768.         flag = islower(input_char);
  3769.     ISPRINT                                                         ISPRINT
  3770.     
  3771.     
  3772.     
  3773.     PROTOTYPE:
  3774.     
  3775.         int isprint(char c)
  3776.     
  3777.     
  3778.     ARGUMENTS:
  3779.     
  3780.         c       - Any character value
  3781.     
  3782.     
  3783.     RETURN VALUE:
  3784.     
  3785.         1 if 'c' is a printable character
  3786.         0 if 'c' is not printable
  3787.     
  3788.     
  3789.     DESCRIPTION:
  3790.     
  3791.           Returns TRUE (1) if the passed character 'c' is a printable  ASCII
  3792.        character, otherwise FALSE (0) is returned.
  3793.     
  3794.     
  3795.     EXAMPLES:
  3796.     
  3797.         while(isprint(*ptr))
  3798.             ++ptr;
  3799.     ISPUNCT                                                         ISPUNCT
  3800.     
  3801.     
  3802.     
  3803.     PROTOTYPE:
  3804.     
  3805.         int ispunct(char c)
  3806.     
  3807.     
  3808.     ARGUMENTS:
  3809.     
  3810.         c       - Any character value
  3811.     
  3812.     
  3813.     RETURN VALUE:
  3814.     
  3815.         1 if 'c' is a printable non-alphanumeric character
  3816.         0 if 'c' is not printable or alphanumeric
  3817.     
  3818.     
  3819.     DESCRIPTION:
  3820.     
  3821.           Returns TRUE (1) if the passed character 'c' is a printable  ASCII
  3822.        character which is not a letter of the alphabet or a  numeric  digit,
  3823.        otherwise FALSE (0) is returned.
  3824.     
  3825.     
  3826.     EXAMPLES:
  3827.     
  3828.         while(ispunct(*ptr))
  3829.             ++ptr;
  3830.     ISSPACE                                                         ISSPACE
  3831.     
  3832.     
  3833.     
  3834.     PROTOTYPE:
  3835.     
  3836.         int isspace(char c)
  3837.     
  3838.     
  3839.     ARGUMENTS:
  3840.     
  3841.         c       - Any character value
  3842.     
  3843.     
  3844.     RETURN VALUE:
  3845.     
  3846.         1 if 'c' is a space character (space, tab or newline)
  3847.         0 if 'c' is not a space character
  3848.     
  3849.     
  3850.     DESCRIPTION:
  3851.     
  3852.           Returns TRUE (1) if the passed character 'c' is one  of  a  space,
  3853.        tab or newline, otherwise FALSE (0) is returned.
  3854.     
  3855.     
  3856.     EXAMPLES:
  3857.     
  3858.         while(isspace(*ptr))
  3859.             ++ptr;
  3860.     ISUPPER                                                         ISUPPER
  3861.     
  3862.     
  3863.     
  3864.     PROTOTYPE:
  3865.     
  3866.         int isupper(char c)
  3867.     
  3868.     
  3869.     ARGUMENTS:
  3870.     
  3871.         c       - Any character value
  3872.     
  3873.     
  3874.     RETURN VALUE:
  3875.     
  3876.         1 if 'c' is upper case alphabetic
  3877.         0 if 'c' is not upper case alphabetic
  3878.     
  3879.     
  3880.     DESCRIPTION:
  3881.     
  3882.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  3883.        alphabetic letter of upper case, otherwise FALSE (0) is returned.
  3884.     
  3885.     
  3886.     EXAMPLES:
  3887.     
  3888.         flag = isupper(input_char);
  3889.     ISXDIGIT                                                       ISXDIGIT
  3890.     
  3891.     
  3892.     
  3893.     PROTOTYPE:
  3894.     
  3895.         int isxdigit(char c)
  3896.     
  3897.     
  3898.     ARGUMENTS:
  3899.     
  3900.         c       - Any character value
  3901.     
  3902.     
  3903.     RETURN VALUE:
  3904.     
  3905.         1 if 'c' is a hexidecimal digit
  3906.         0 if 'c' is not a hexidecimal digit
  3907.     
  3908.     
  3909.     DESCRIPTION:
  3910.     
  3911.           Returns TRUE (1) is the passed character 'c'  is  an  valid  ASCII
  3912.        hexidecimal digit ('0'-'9', 'A'-'F', 'a'-'f'), otherwise FALSE (0) is
  3913.        returned.
  3914.     
  3915.     
  3916.     EXAMPLES:
  3917.     
  3918.         value = 0;
  3919.         while(isxdigit(*ptr))
  3920.             value = (value * 16) +
  3921.                 (isdigit(*ptr) ? *ptr++ - '0' : toupper(*ptr++) - ('A'-10));
  3922.     LONGJMP                                                         LONGJMP
  3923.     
  3924.     
  3925.     
  3926.     PROTOTYPE:
  3927.     
  3928.         longjmp(int savenv[2], int rvalue)
  3929.     
  3930.     
  3931.     ARGUMENTS:
  3932.     
  3933.         savenv  - Save area for program context
  3934.         rvalue  - Value to be returned by "setjmp"
  3935.     
  3936.     
  3937.     RETURN VALUE:
  3938.     
  3939.         N/A - Function never returns
  3940.     
  3941.     
  3942.     DESCRIPTION:
  3943.     
  3944.           The  "longjmp"  function  causes  execution  to  transfer  to  the
  3945.        "setjmp" call which  set  up  the  "savenv"  variable.  The  "setjmp"
  3946.        function will appear to return the value of "rvalue".
  3947.     
  3948.           NOTE-1: "longjmp" may  only  be  used  from  within  the  function
  3949.        calling "setjmp" or a function which has been called  "beneath"  that
  3950.        function. IT MUST NOT BE USED AFTER THE FUNCTION CALLING "SETJMP" HAS
  3951.        TERMINATED.
  3952.     
  3953.           NOTE-2: If "rvalue" is zero, the function  calling  "setjmp"  will
  3954.        assume that it is returning from initialization. Unless you want this
  3955.        unusual behavior, you should not pass  a  return  value  of  zero  to
  3956.        "longjmp".
  3957.     
  3958.           See also SETJMP.
  3959.     
  3960.     
  3961.     EXAMPLES:
  3962.     
  3963.         if(getch() == ('C'-'@'))        /* If Control-C entered... */
  3964.             longjmp(savearea, 1);       /* Return to main function */
  3965.     LONGMATH                                                       LONGMATH
  3966.     
  3967.     
  3968.     
  3969.     PROTOTYPES:
  3970.     
  3971.         int longadd(char *num1, char *num2);
  3972.         int longsub(char *num1, char *num2);
  3973.         longmul(char *num1, char *num2);
  3974.         longdiv(char *num1, char *num2);
  3975.         int longshr(char *num1);
  3976.         int longshl(char *num1);
  3977.         longcpy(char *num1, char *num2);
  3978.         longset(char *num1, unsigned value);
  3979.         int longtst(char *num1);
  3980.         int longcmp(char *num1, char *num2);
  3981.         extern char Longreg[];
  3982.     
  3983.     ARGUMENTS:
  3984.     
  3985.         num1    - First LONG operand, receives result if generated
  3986.         num2    - Second LONG operand, is not altered
  3987.         value   - 16 bit value to initialize LONG number
  3988.     
  3989.     
  3990.     RETURN VALUE:
  3991.     
  3992.         longadd - 0 = Ok, 1 = addition overflowed
  3993.         longsub - 0 = Ok, 1 = subtraction underflowed
  3994.         longshr - Carry out of shift (1/0)
  3995.         longshl - Carry out of shift (1/0)
  3996.         longtst - 0 = Number is zero, !0 = Number is not zero
  3997.         longcmp - 0 = (num1 == num2), 1 = (num1 > num2), -1 = (num1 < num2)
  3998.     
  3999.     
  4000.     DESCRIPTION:
  4001.     
  4002.           This set of functions performs basic arithmetic functions on  LONG
  4003.        numbers:
  4004.     
  4005.         longadd(num1, num2)     ->  num1 += num2
  4006.         longsub(num1, num2)     ->  num1 -= num2
  4007.         longmul(num1, num2)     ->  num1 *= num2 , Longreg = num1 * num2
  4008.         longdiv(num1, num2)     ->  num1 /= num2 , Longreg = num1 % num2
  4009.         longshr(num1)           ->  num1 >>= 1
  4010.         longshl(num1)           ->  num1 <<= 1
  4011.         longcpy(num1, num2)     ->  num1 = num2
  4012.         longset(num1, value)    ->  num1 = (long) value
  4013.         longtst(num1)           ->  Test (num1 != 0)
  4014.         longcmp(num1, num2)     ->  Compare num1 and num2
  4015.     
  4016.           As shipped, a LONG number is 32 bits (4 bytes)  in  size,  however
  4017.        this can be changed by altering the LONGMATH.ASM in the library.
  4018.     
  4019.           For a complete example of using  these  functions,  refer  to  the
  4020.        LONGCALC.C example program included with the package.
  4021.     MALLOC                                                           MALLOC
  4022.     
  4023.     
  4024.     
  4025.     PROTOTYPE:
  4026.     
  4027.         char *malloc(int size)
  4028.     
  4029.     
  4030.     ARGUMENTS:
  4031.     
  4032.         size    - Size of memory block to allocate (in bytes).
  4033.     
  4034.     
  4035.     RETURN VALUE:
  4036.     
  4037.         0       - Memory allocation failed
  4038.         !0      - Pointer to allocated memory block
  4039.     
  4040.     
  4041.     DESCRIPTION:
  4042.     
  4043.           The "malloc" function allocates a block of memory of the specified
  4044.        size from the heap, and returns a pointer to  it.  This  memory  will
  4045.        remain allocated until it is  explicitly  released  with  the  "free"
  4046.        function.
  4047.     
  4048.     
  4049.     EXAMPLES:
  4050.     
  4051.         if(!(ptr = malloc(BUFSIZ)))     /* Allocate a temporary buffer */
  4052.             abort("Not enough memory");
  4053.         /* ... Use the memory block ... */
  4054.         free(ptr);                      /* Release temporary buffer */
  4055.     MAX                                                                 MAX
  4056.     
  4057.     
  4058.     
  4059.     PROTOTYPE:
  4060.     
  4061.         int max(int value1, int value2)
  4062.     
  4063.     
  4064.     ARGUMENTS:
  4065.     
  4066.         value1  - Any integer value
  4067.         value2  - Any integer value
  4068.     
  4069.     
  4070.     RETURN VALUE:
  4071.     
  4072.         The greater of "value1" or "value2"
  4073.     
  4074.     
  4075.     DESCRIPTION:
  4076.     
  4077.           The "max" function returns the higher of its two argument values.
  4078.     
  4079.     
  4080.     EXAMPLES:
  4081.     
  4082.         biggest = max(a, b);
  4083.     MEMCPY                                                           MEMCPY
  4084.     
  4085.     
  4086.     
  4087.     PROTOTYPE:
  4088.     
  4089.         memcpy(char *dest, char *source, unsigned size)
  4090.     
  4091.     
  4092.     ARGUMENTS:
  4093.     
  4094.         dest    - Pointer to the destination
  4095.         source  - Pointer to the souce
  4096.         size    - Number of bytes to copy
  4097.     
  4098.     
  4099.     RETURN VALUE:
  4100.     
  4101.         None
  4102.     
  4103.     
  4104.     DESCRIPTION:
  4105.     
  4106.           The "memcpy" function will copy the specified number of bytes from
  4107.        the source to the destination.
  4108.     
  4109.     
  4110.     EXAMPLES:
  4111.     
  4112.         memcpy(buffer1, buffer2, 256);
  4113.     MEMSET                                                           MEMSET
  4114.     
  4115.     
  4116.     
  4117.     PROTOTYPE:
  4118.     
  4119.         memset(char *block, char value, unsigned size)
  4120.     
  4121.     
  4122.     ARGUMENTS:
  4123.     
  4124.         block   - Pointer to a block of memory
  4125.         value   - Value to initialize memory with
  4126.         size    - Number of bytes to initialize
  4127.     
  4128.     
  4129.     RETURN VALUE:
  4130.     
  4131.         None
  4132.     
  4133.     
  4134.     DESCRIPTION:
  4135.     
  4136.           Sets a block of memory  beginning  at  the  pointer  "block",  for
  4137.        "size" bytes to the byte value "value".
  4138.     
  4139.     
  4140.     EXAMPLES:
  4141.     
  4142.         memset(buffer, 0, 100);
  4143.     MIN                                                                 MIN
  4144.     
  4145.     
  4146.     
  4147.     PROTOTYPE:
  4148.     
  4149.         int min(int value1, int value2)
  4150.     
  4151.     
  4152.     ARGUMENTS:
  4153.     
  4154.         value1  - Any integer value
  4155.         value2  - Any integer value
  4156.     
  4157.     
  4158.     RETURN VALUE:
  4159.     
  4160.         The smaller of "value1" or "value2"
  4161.     
  4162.     
  4163.     DESCRIPTION:
  4164.     
  4165.           The "min" function returns the lower of its two argument values.
  4166.     
  4167.     
  4168.     EXAMPLES:
  4169.     
  4170.         least = min(a, b);
  4171.     NARGS                                                             NARGS
  4172.     
  4173.     
  4174.     
  4175.     PROTOTYPE:
  4176.     
  4177.         int nargs()
  4178.     
  4179.     
  4180.     ARGUMENTS:
  4181.     
  4182.         None
  4183.     
  4184.     
  4185.     RETURN VALUE:
  4186.     
  4187.         The number of arguments passed to the calling function
  4188.     
  4189.     
  4190.     DESCRIPTION:
  4191.     
  4192.           Returns the number of arguments passed to a "register" function.
  4193.     
  4194.           NOTE: When  calling  a  "register"  function,  MICRO-C  loads  the
  4195.        accumulator with the number of arguments just prior  to  calling  the
  4196.        function. This "nargs" routine is  simply  a  null  definition  which
  4197.        returns with the same value in the accumulator as was there  when  it
  4198.        was called. Therefore "nargs" MUST BE  THE  FIRST  ARITHMETIC  ENTITY
  4199.        EVALUATED WITHIN  THE  REGISTER  FUNCTION  or  the  contents  of  the
  4200.        accumulator will be lost. Some examples of "register" definitions and
  4201.        the use of "nargs" may be found in the library source code.
  4202.     
  4203.     
  4204.     EXAMPLES:
  4205.     
  4206.         first_arg = nargs() * 2 + &arguments;
  4207.     OUTPx                                                             OUTPx
  4208.     
  4209.     
  4210.     
  4211.     PROTOTYPE:
  4212.     
  4213.         outp1(char value);
  4214.         outp2(char value);
  4215.         outp3(char value);
  4216.         outp4(char value);
  4217.     
  4218.     
  4219.     ARGUMENTS:
  4220.     
  4221.         value   - 8 bit value to be written to port.
  4222.     
  4223.     
  4224.     RETURN VALUE:
  4225.     
  4226.         None
  4227.     
  4228.     
  4229.     DESCRIPTION:
  4230.     
  4231.           These functions write an 8 bit value to a parallel I/O port.
  4232.     
  4233.     
  4234.     EXAMPLES:
  4235.     
  4236.         if(inp1() & 0x01)
  4237.             outp2(inp2() | 0x01);
  4238.     PEEK                                                               PEEK
  4239.     
  4240.     
  4241.     
  4242.     PROTOTYPE:
  4243.     
  4244.         int peek(unsigned address)
  4245.     
  4246.     
  4247.     ARGUMENTS:
  4248.     
  4249.         address - 16 bit memory address
  4250.     
  4251.     
  4252.     RETURN VALUE:
  4253.     
  4254.         The 8 bit value read from the given memory address
  4255.     
  4256.     
  4257.     DESCRIPTION:
  4258.     
  4259.           The "peek" function reads and returns a byte (8 bits) from  memory
  4260.        as an integer value between 0 and 255.
  4261.     
  4262.     
  4263.     EXAMPLES:
  4264.     
  4265.         while(peek(0)); /* Wait for flag to clear */
  4266.     PEEKW                                                             PEEKW
  4267.     
  4268.     
  4269.     
  4270.     PROTOTYPE:
  4271.     
  4272.         int peekw(unsigned address)
  4273.     
  4274.     
  4275.     ARGUMENTS:
  4276.     
  4277.         address - 16 bit memory address
  4278.     
  4279.     
  4280.     RETURN VALUE:
  4281.     
  4282.         The 16 bit value read from the given memory address
  4283.     
  4284.     
  4285.     DESCRIPTION:
  4286.     
  4287.           The "peekw" function reads and  returns  a  word  (16  bits)  from
  4288.        memory as an integer value between 0 and 65535 (-1).
  4289.     
  4290.     
  4291.     EXAMPLES:
  4292.     
  4293.         var = peekw(0));
  4294.     POKE                                                               POKE
  4295.     
  4296.     
  4297.     
  4298.     PROTOTYPE:
  4299.     
  4300.         poke(unsigned address, char value)
  4301.     
  4302.     
  4303.     ARGUMENTS:
  4304.     
  4305.         address - 16 bit memory address
  4306.         value   - Value to be written to memory
  4307.     
  4308.     
  4309.     RETURN VALUE:
  4310.     
  4311.         None
  4312.     
  4313.     
  4314.     DESCRIPTION:
  4315.     
  4316.           The "poke" function writes a byte (8 bit) value to memory.
  4317.     
  4318.     
  4319.     EXAMPLES:
  4320.     
  4321.         poke(0, 0);     /* Write 0 to location 0 */
  4322.     POKEW                                                             POKEW
  4323.     
  4324.     
  4325.     
  4326.     PROTOTYPE:
  4327.     
  4328.         pokew(unsigned address, int value)
  4329.     
  4330.     
  4331.     ARGUMENTS:
  4332.     
  4333.         address - 16 bit memory address
  4334.         value   - Value to be written to memory
  4335.     
  4336.     
  4337.     RETURN VALUE:
  4338.     
  4339.         None
  4340.     
  4341.     
  4342.     DESCRIPTION:
  4343.     
  4344.           The "pokew" function writes a word (16 bit) value to memory.
  4345.     
  4346.     
  4347.     EXAMPLES:
  4348.     
  4349.         pokew(0, 0);    /* Write 0 to locations 0 and 1 */
  4350.     PRINTF                                                           PRINTF
  4351.     
  4352.     
  4353.     
  4354.     PROTOTYPE:
  4355.     
  4356.         register printf(char *format, arg, ...)
  4357.     
  4358.     
  4359.     ARGUMENTS:
  4360.     
  4361.         format  - Pointer to format string
  4362.         arg     - Argument as determined by format string
  4363.         ...     - Additional arguments may be required
  4364.     
  4365.     
  4366.     RETURN VALUE:
  4367.     
  4368.         None
  4369.     
  4370.     
  4371.     DESCRIPTION:
  4372.     
  4373.     
  4374.           The "printf" function performs a formatted print to console serial
  4375.        port. The 'format' string is written to  the  serial  port  with  the
  4376.        arguments substituted  for  special  "conversion  characters".  These
  4377.        "conversion characters" are identified by a preceeding '%',  and  may
  4378.        be one of the following:
  4379.     
  4380.                     b       - Binary number
  4381.                     c       - Character
  4382.                     d       - Decimal (signed) number
  4383.                     o       - Octal number
  4384.                     s       - String
  4385.                     u       - Unsigned decimal number
  4386.                     x       - Hexidecimal number
  4387.                     %       - A single percent sign (No argument used)
  4388.     
  4389.           A numeric "field width" specifier may be placed in between the '%'
  4390.        and the conversion character, in which case the value will be  output
  4391.        in a field of that width. If the "field width" is a negative  number,
  4392.        the output will be left justified in the field, otherwise it is right
  4393.        justified. If the field width contains a leading '0', then the output
  4394.        field will be padded with zero's, otherwise spaces are used.
  4395.     
  4396.           If no "field width" is given, the output  is  free  format,  using
  4397.        only as much space as required.
  4398.     
  4399.           NOTE: This function uses a variable number of arguments, and  must
  4400.        be declared as "register" (See "stdio.h").
  4401.     
  4402.     
  4403.     EXAMPLES:
  4404.     
  4405.         printf("Hello world!!!\n");
  4406.         printf("%u interrupts have occured!\n", int_count);
  4407.     PUTCH                                                             PUTCH
  4408.     
  4409.     
  4410.     
  4411.     PROTOTYPE:
  4412.     
  4413.         putch(char c)
  4414.     
  4415.     
  4416.     ARGUMENTS:
  4417.     
  4418.         c       - Any character value
  4419.     
  4420.     
  4421.     RETURN VALUE:
  4422.     
  4423.         None
  4424.     
  4425.     
  4426.     DECRIPTION:
  4427.     
  4428.           This function writes the character 'c' to the console serial port.
  4429.        The NEWLINE character is translated into a LINE-FEED, followed  by  a
  4430.        CARRIAGE return, which causes the printing position to advance to the
  4431.        first column of the next line.
  4432.     
  4433.     
  4434.     EXAMPLES:
  4435.     
  4436.         putch('*');
  4437.         putch('\n');
  4438.     PUTCHR                                                           PUTCHR
  4439.     
  4440.     
  4441.     
  4442.     PROTOTYPE:
  4443.     
  4444.         putchr(char c)
  4445.     
  4446.     
  4447.     ARGUMENTS:
  4448.     
  4449.         c       - Any character value
  4450.     
  4451.     
  4452.     RETURN VALUE:
  4453.     
  4454.         None
  4455.     
  4456.     
  4457.     DECRIPTION:
  4458.     
  4459.           This function writes the character 'c' to the console serial port.
  4460.        The character is written in "raw" format, with no translations of any
  4461.        kind.
  4462.     
  4463.     
  4464.     EXAMPLES:
  4465.     
  4466.         putchr('*');
  4467.         putchr('\r');
  4468.     PUTSTR                                                           PUTSTR
  4469.     
  4470.     
  4471.     
  4472.     PROTOTYPE:
  4473.     
  4474.         putstr(char *string)
  4475.     
  4476.     
  4477.     ARGUMENTS:
  4478.     
  4479.         string  - Pointer to a character string
  4480.     
  4481.     
  4482.     RETURN VALUE:
  4483.     
  4484.         0 if successful, otherwise an operating system error code
  4485.     
  4486.     
  4487.     DESCRIPTION:
  4488.     
  4489.           The "putstr" function writes the specified string  to  the  serial
  4490.        port. The zero terminating the string is NOT written.
  4491.     
  4492.     
  4493.     EXAMPLES:
  4494.     
  4495.         putstr("Text message");
  4496.     RAND                                                               RAND
  4497.     
  4498.     
  4499.     
  4500.     PROTOTYPE:
  4501.     
  4502.         unsigned rand(unsigned limit)
  4503.     
  4504.     
  4505.     ARGUMENTS:
  4506.     
  4507.         limit   - Maximum value to return
  4508.     
  4509.     
  4510.     RETURN VALUE:
  4511.     
  4512.         A pseudo-random number in the range of 0 to (limit-1)
  4513.     
  4514.     
  4515.     DESCRIPTION:
  4516.     
  4517.           The "rand" function calculates the next value of  a  pseudo-random
  4518.        sequence, based on a 16 bit unsigned "seed" value, which it maintains
  4519.        in the global variable "RANDSEED". The new value is stored as the new
  4520.        seed value, and is then divided by the "limit" parameter,  to  obtain
  4521.        the remainder, which is returned. This results in a random number  in
  4522.        the range of zero (0) to (limit - 1).
  4523.     
  4524.           Any  particular  sequence  may  be  repeated,  by   reseting   the
  4525.        "RANDSEED" value.
  4526.     
  4527.     
  4528.     EXAMPLES:
  4529.     
  4530.         value = rand(52);
  4531.     SETJMP                                                           SETJMP
  4532.     
  4533.     
  4534.     
  4535.     PROTOTYPE:
  4536.     
  4537.         int setjmp(int savenv[2])
  4538.     
  4539.     
  4540.     ARGUMENTS:
  4541.     
  4542.         savenv  - Save area for program context
  4543.     
  4544.     
  4545.     RETURN VALUE:
  4546.     
  4547.         0 is returned when actually called
  4548.         Value passed to "longjmp" is returned otherwise
  4549.     
  4550.     
  4551.     DESCRIPTION:
  4552.     
  4553.           When called, the "setjmp" function stores  the  current  execution
  4554.        state of the program into the passed integer array, and  returns  the
  4555.        value zero.
  4556.     
  4557.           The "longjmp" function may then be used to return the  program  to
  4558.        the "setjmp" call. In this case, the value returned by "setjmp"  will
  4559.        be the value which was passed to "longjmp". This allows the  function
  4560.        containing "setjmp" to determine which call to  "longjmp"  transfered
  4561.        execution to it.
  4562.     
  4563.           See also LONGJMP.
  4564.     
  4565.     
  4566.     EXAMPLES:
  4567.     
  4568.         switch(setjmp(savearea)) {
  4569.             case 0 : printf("Longjmp has been set up"); break;
  4570.             case 1 : printf("Control-C Interrupt");     break;
  4571.             case 2 : printf("Reset command executed");  break;
  4572.             default: printf("Software error trap");     break; }
  4573.     SPRINTF                                                         SPRINTF
  4574.     
  4575.     
  4576.     
  4577.     PROTOTYPE:
  4578.     
  4579.         register sprintf(char *dest, char *format, arg, ...)
  4580.     
  4581.     
  4582.     ARGUMENTS:
  4583.     
  4584.         dest    - Pointer to destination string
  4585.         format  - Pointer to format string
  4586.         arg     - Argument as determined by format string
  4587.         ...     - Additional arguments may be required
  4588.     
  4589.     
  4590.     RETURN VALUE:
  4591.     
  4592.         None
  4593.     
  4594.     
  4595.     DESCRIPTION:
  4596.     
  4597.           The "sprintf" routine performs a formatted print to  a  string  in
  4598.        memory. The "format" string is written to the destination string with
  4599.        the arguments substituted for special "conversion characters".
  4600.     
  4601.           See "printf" for more information on format strings.
  4602.     
  4603.           NOTE: This function uses a variable number of arguments, and  must
  4604.        be declared as "register" (See "stdio.h").
  4605.     
  4606.     
  4607.     EXAMPLES:
  4608.     
  4609.         sprintf(header_file, "/lib/%s.h", header_name);
  4610.     SQRT                                                               SQRT
  4611.     
  4612.     
  4613.     
  4614.     PROTOTYPE:
  4615.     
  4616.         int sqrt(unsigned value)
  4617.     
  4618.     
  4619.     ARGUMENTS:
  4620.     
  4621.         value   - Number for which to calculate square root
  4622.     
  4623.     
  4624.     RETURN VALUE:
  4625.     
  4626.         The integer square root (rounded up) of the argument value
  4627.     
  4628.     
  4629.     DESCRIPTION:
  4630.     
  4631.           The  SQRT  function  returns  the  smallest  number   which   when
  4632.        multiplied by itself will give a number equal to or larger  that  the
  4633.        argument value.
  4634.     
  4635.     
  4636.     EXAMPLES:
  4637.     
  4638.     /*
  4639.      * Draw a circle about point (x, y) of radus (r)
  4640.      */
  4641.     circle(x, y, r)
  4642.         int x, y, r;
  4643.     {
  4644.         int i, j, k, rs, lj;
  4645.     
  4646.         rs = (lj = r)*r;
  4647.         for(i=0; i <= r; ++i) {
  4648.             j = k = sqrt(rs - (i*i));
  4649.             do {
  4650.                 plot_xy(x+i, y+j);
  4651.                 plot_xy(x+i, y-j);
  4652.                 plot_xy(x-i, y+j);
  4653.                 plot_xy(x-i, y-j); }
  4654.             while(++j < lj);
  4655.             lj = k; }
  4656.     }
  4657.     STRCAT                                                           STRCAT
  4658.     
  4659.     
  4660.     
  4661.     PROTOTYPE:
  4662.     
  4663.         char *strcat(char *dest, char *source)
  4664.     
  4665.     
  4666.     ARGUMENTS:
  4667.     
  4668.         dest    - Pointer to destination string
  4669.         source  - Pointer to source string
  4670.     
  4671.     
  4672.     RETURN VALUE:
  4673.     
  4674.         Pointer to zero terminating destination string
  4675.     
  4676.     
  4677.     DESCRIPTION:
  4678.     
  4679.           This function concatinates the source string onto the tail of  the
  4680.        destination string. The destination string must be  large  enough  to
  4681.        hold the entire contents of both strings.
  4682.     
  4683.     
  4684.     EXAMPLES:
  4685.     
  4686.         strcat(program_name, ".c");
  4687.     STRCHR                                                           STRCHR
  4688.     
  4689.     
  4690.     
  4691.     PROTOTYPE:
  4692.     
  4693.         char *strchr(char *string, char chr)
  4694.     
  4695.     
  4696.     ARGUMENTS:
  4697.     
  4698.         string  - Pointer to a character string
  4699.         chr     - Character to look for
  4700.     
  4701.     
  4702.     RETURN VALUE:
  4703.     
  4704.         Pointer to the first occurance of 'chr' in 'string'
  4705.         Zero (0) if character was not found
  4706.     
  4707.     
  4708.     DECRIPTION:
  4709.     
  4710.           Searches  the  passed  string  got  the  first  occurance  of  the
  4711.        specified character. If the character is  found,  a  pointer  to  its
  4712.        position in the string is returned. If the character is not found,  a
  4713.        null pointer is returned.
  4714.     
  4715.           The null (0) character is treated as valid data by this  function,
  4716.        thus:
  4717.           strchr(string, 0);
  4718.     
  4719.        would return the position of the null terminator of the string.
  4720.     
  4721.     
  4722.     EXAMPLES:
  4723.     
  4724.         comma = strchr(buffer, ',');
  4725.     STRCMP                                                           STRCMP
  4726.     
  4727.     
  4728.     
  4729.     PROTOTYPE:
  4730.     
  4731.         int strcmp(char *string1, char *string2)
  4732.     
  4733.     
  4734.     ARGUMENTS:
  4735.     
  4736.         string1 - Pointer to first string
  4737.         string2 - Pointer to second string
  4738.     
  4739.     
  4740.     RETURN VALUE:
  4741.     
  4742.         0   - Strings match exactly
  4743.         1   - String1 is greater than string2
  4744.         -1  - String2 is greater than string1
  4745.     
  4746.     
  4747.     DESCRIPTION:
  4748.     
  4749.           This function compares two strings character by character. If  the
  4750.        two strings are identical, a zero  (0)  is  returned.  If  the  first
  4751.        string is greater than the second (as far as ASCII is  concerned),  a
  4752.        one (1) is returned. If the second string is greater, a negative  one
  4753.        (-1) is returned.
  4754.     
  4755.     
  4756.     EXAMPLES:
  4757.     
  4758.         if(!strcmp(command, "quit"))
  4759.             exit(0);
  4760.     STRCPY                                                           STRCPY
  4761.     
  4762.     
  4763.     
  4764.     PROTOTYPE:
  4765.     
  4766.         char *strcpy(char *dest, char *source)
  4767.     
  4768.     
  4769.     ARGUMENTS:
  4770.     
  4771.         dest    - Pointer to destination string
  4772.         souce   - Pointer to source string
  4773.     
  4774.     
  4775.     RETURN VALUE:
  4776.     
  4777.         Pointer to zero terminating destination string
  4778.     
  4779.     
  4780.     DESCRIPTION:
  4781.     
  4782.           This function copies the source string to the destination  string.
  4783.        All data is copied up to and including the zero byte which terminates
  4784.        the string. The destination string must be large enough to  hold  the
  4785.        entire source.
  4786.     
  4787.     
  4788.     EXAMPLES:
  4789.     
  4790.         strcpy(filename, argv[1]);
  4791.     STRLEN                                                           STRLEN
  4792.     
  4793.     
  4794.     
  4795.     PROTOTYPE:
  4796.     
  4797.         int strlen(char *string)
  4798.     
  4799.     
  4800.     ARGUMENTS:
  4801.     
  4802.         string  - Pointer to a character string
  4803.     
  4804.     
  4805.     RETURN VALUE:
  4806.     
  4807.         The length of the string
  4808.     
  4809.     
  4810.     DECRIPTION:
  4811.     
  4812.           Returns the length in character of the passed string.  The  length
  4813.        does not include the zero byte which terminates the string.
  4814.     
  4815.     
  4816.     EXAMPLES:
  4817.     
  4818.         length = strlen(command);
  4819.     TOLOWER                                                         TOLOWER
  4820.     
  4821.     
  4822.     
  4823.     PROTOTYPE:
  4824.     
  4825.         char tolower(char c)
  4826.     
  4827.     
  4828.     ARGUMENTS:
  4829.     
  4830.         c   - Any character value
  4831.     
  4832.     
  4833.     RETURN VALUE:
  4834.     
  4835.         The value of 'c', converted to lower case
  4836.     
  4837.     
  4838.     DESCRIPTION:
  4839.     
  4840.           Returns the value of 'c' converted to lower case. If 'c' is not  a
  4841.        letter of upper case, no change is made, and the  original  value  of
  4842.        'c' is returned.
  4843.     
  4844.     
  4845.     EXAMPLES:
  4846.     
  4847.         input_char = tolower(getch());
  4848.     TOUPPER                                                         TOUPPER
  4849.     
  4850.     
  4851.     
  4852.     PROTOTYPE:
  4853.     
  4854.         char toupper(char c)
  4855.     
  4856.     
  4857.     ARGUMENTS:
  4858.     
  4859.         c   - Any character value
  4860.     
  4861.     
  4862.     RETURN VALUE:
  4863.     
  4864.         The value of 'c', converted to upper case
  4865.     
  4866.     
  4867.     DESCRIPTION:
  4868.     
  4869.           Returns the value of 'c' converted to upper case. If 'c' is not  a
  4870.        letter of lower case, no change is made, and the  original  value  of
  4871.        'c' is returned.
  4872.     
  4873.     
  4874.     EXAMPLES:
  4875.     
  4876.         putch(toupper(output_char));
  4877.  
  4878.  
  4879.  
  4880.                             MICRO-C C-FLEA Compiler
  4881.  
  4882.                                TABLE OF CONTENTS
  4883.  
  4884.  
  4885.                                                                          Page
  4886.  
  4887.      1. INTRODUCTION                                                        1
  4888.  
  4889.         1.1 Memory configuration                                            1
  4890.         1.2 Code Portability                                                1
  4891.         1.3 The compiling process                                           2
  4892.  
  4893.      2. THE COMMAND CO-ORDINATOR                                            3
  4894.  
  4895.         2.1 The CCF command                                                 3
  4896.  
  4897.      3. THE MICRO-C PROGRAMMING LANGUAGE                                    5
  4898.  
  4899.         3.1 Constants                                                       5
  4900.         3.2 Symbols                                                         5
  4901.         3.3 Arrays & Pointers                                               9
  4902.         3.4 Functions                                                       9
  4903.         3.5 Structures & Unions                                            10
  4904.         3.6 Control Statements                                             13
  4905.         3.7 Expression Operators                                           15
  4906.         3.8 Inline Assembly Language                                       17
  4907.         3.9 Preprocessor Commands                                          18
  4908.         3.10 Error Messages                                                19
  4909.         3.11 Quirks                                                        24
  4910.  
  4911.      4. ADVANCED TOPICS                                                    28
  4912.  
  4913.         4.1 Conversion Rules                                               28
  4914.         4.2 Assembly Language Interface                                    29
  4915.         4.3 Compiling for ROM                                              31
  4916.  
  4917.      5. THE MICRO-C COMPILER                                               32
  4918.  
  4919.         5.1 The MCCCF command                                              32
  4920.  
  4921.      6. THE MICRO-C PREPROCESSOR                                           33
  4922.  
  4923.         6.1 The MCP command                                                34
  4924.         6.2 Preprocesor Commands                                           35
  4925.         6.3 Error messages                                                 38
  4926.  
  4927.      7. THE MICRO-C OPTIMIZER                                              40
  4928.  
  4929.         7.1 The MCOCF command                                              40
  4930.  
  4931.      8. THE SOURCE LINKER                                                  41
  4932.  
  4933.         8.1 The SLINK Command                                              41
  4934.  
  4935.     MICRO-C C-FLEA Compiler                                Table of Contents
  4936.  
  4937.                                                                          Page
  4938.         8.2 Multiple Input Files                                           42
  4939.         8.3 The External Index File                                        43
  4940.         8.4 Source file information                                        45
  4941.         8.5 The SCONVERT command                                           46
  4942.         8.6 The SRENUM command                                             47
  4943.         8.7 The SINDEX command                                             48
  4944.         8.8 The SLIB command                                               48
  4945.         8.9 Making a source library                                        50
  4946.  
  4947.      9. THE MAKE UTILITY                                                   51
  4948.  
  4949.         9.1 MAKEfiles                                                      51
  4950.         9.2 Directives                                                     54
  4951.         9.3 The MAKE command                                               55
  4952.         9.4 The TOUCH command                                              56
  4953.  
  4954.      10. EDT - Text editor                                                 57
  4955.  
  4956.         10.1 Introduction                                                  57
  4957.         10.2 Line mode operation                                           57
  4958.         10.3 Visual mode operation                                         62
  4959.  
  4960.      11. The MICRO-C/C-FLEA Library                                        66
  4961.  
  4962.